# AC: 577 msec (Python3)
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def string_to_number(a):
    return 1 << (ord(a) - 97)

class SegmentTree:
    def __init__(self, A):
        self.n = 2**(len(A)-1).bit_length()
        self.identity = 0
        self.seg = [self.identity] * (2 * self.n)
        
        for i, a in enumerate(A):
            self.seg[self.n-1+i] = string_to_number(a)
        for i in range(self.n-2,-1,-1):
            self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2]

            
    def update(self, k, a):
        k += self.n - 1
        self.seg[k] = string_to_number(a)
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2]

            
    def query(self, a, b):
        if b == a:
        	return 1
        a += self.n - 1
        b += self.n - 2
        res = self.identity
        while b - a > 1:
            if not a & 1:
                res |= self.seg[a]
            if b & 1:
                res |= self.seg[b]
                b -= 2
            a >>= 1
            b -= 1
            b >>= 1
        if a == b:
            res |= self.seg[a]
        else:
            res |= (self.seg[a] | self.seg[b])
        
        return bin(res).count("1")


def main():
    N = int(readline())
    s = readline().strip()
    seg = SegmentTree(list(s))

    Q = int(readline())
    q = map(str, read().split())
    ans = []
    for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            ans.append(seg.query(int(a)-1, int(b)))
    
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines def string_to_number(a):
    return 1 << (ord(a) - 97) string_to_number return 1 << (ord(a) - 97) 1 << (ord(a) - 97) 1 ord(a) - 97 ord(a) ord a 97 a a class SegmentTree:
    def __init__(self, A):
        self.n = 2**(len(A)-1).bit_length()
        self.identity = 0
        self.seg = [self.identity] * (2 * self.n)
        
        for i, a in enumerate(A):
            self.seg[self.n-1+i] = string_to_number(a)
        for i in range(self.n-2,-1,-1):
            self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2]

            
    def update(self, k, a):
        k += self.n - 1
        self.seg[k] = string_to_number(a)
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2]

            
    def query(self, a, b):
        if b == a:
        	return 1
        a += self.n - 1
        b += self.n - 2
        res = self.identity
        while b - a > 1:
            if not a & 1:
                res |= self.seg[a]
            if b & 1:
                res |= self.seg[b]
                b -= 2
            a >>= 1
            b -= 1
            b >>= 1
        if a == b:
            res |= self.seg[a]
        else:
            res |= (self.seg[a] | self.seg[b])
        
        return bin(res).count("1") SegmentTree def __init__(self, A):
        self.n = 2**(len(A)-1).bit_length()
        self.identity = 0
        self.seg = [self.identity] * (2 * self.n)
        
        for i, a in enumerate(A):
            self.seg[self.n-1+i] = string_to_number(a)
        for i in range(self.n-2,-1,-1):
            self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2]

            
     __init__ self.n = 2**(len(A)-1).bit_length() self.n self n 2**(len(A)-1).bit_length() 2 (len(A)-1).bit_length() len(A)-1).bit_length len(A)-1 len(A) len A 1 bit_length self.identity = 0 self.identity self identity 0 self.seg = [self.identity] * (2 * self.n) self.seg self seg [self.identity] * (2 * self.n) [self.identity] self.identity self identity 2 * self.n 2 self.n self n for i, a in enumerate(A):
            self.seg[self.n-1+i] = string_to_number(a)
         i a enumerate(A) enumerate A self.seg[self.n-1+i] = string_to_number(a) self.seg[self.n-1+i] self.seg self seg self.n-1+i self.n-1 self.n self n 1 i string_to_number(a) string_to_number a for i in range(self.n-2,-1,-1):
            self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2]

            
     i range(self.n-2,-1,-1) range self.n-2 self.n self n 2 -1 -1 self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2] self.seg[i] self.seg self seg i self.seg[2*i+1] | self.seg[2*i+2] self.seg[2*i+1] self.seg self seg 2*i+1 2*i 2 i 1 self.seg[2*i+2] self.seg self seg 2*i+2 2*i 2 i 2 self self A A def update(self, k, a):
        k += self.n - 1
        self.seg[k] = string_to_number(a)
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2]

            
     update k += self.n - 1 k self.n - 1 self.n self n 1 self.seg[k] = string_to_number(a) self.seg[k] self.seg self seg k string_to_number(a) string_to_number a while k:
            k = (k - 1) // 2
            self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2]

            
     k k = (k - 1) // 2 k (k - 1) // 2 k - 1 k 1 2 self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2] self.seg[k] self.seg self seg k self.seg[k*2+1] | self.seg[k*2+2] self.seg[k*2+1] self.seg self seg k*2+1 k*2 k 2 1 self.seg[k*2+2] self.seg self seg k*2+2 k*2 k 2 2 self self k k a a def query(self, a, b):
        if b == a:
        	return 1
        a += self.n - 1
        b += self.n - 2
        res = self.identity
        while b - a > 1:
            if not a & 1:
                res |= self.seg[a]
            if b & 1:
                res |= self.seg[b]
                b -= 2
            a >>= 1
            b -= 1
            b >>= 1
        if a == b:
            res |= self.seg[a]
        else:
            res |= (self.seg[a] | self.seg[b])
        
        return bin(res).count("1") query if b == a:
        	return 1
         b == a b a return 1 1 a += self.n - 1 a self.n - 1 self.n self n 1 b += self.n - 2 b self.n - 2 self.n self n 2 res = self.identity res self.identity self identity while b - a > 1:
            if not a & 1:
                res |= self.seg[a]
            if b & 1:
                res |= self.seg[b]
                b -= 2
            a >>= 1
            b -= 1
            b >>= 1
         b - a > 1 b - a b a 1 if not a & 1:
                res |= self.seg[a]
             not a & 1 a & 1 a 1 res |= self.seg[a] res self.seg[a] self.seg self seg a if b & 1:
                res |= self.seg[b]
                b -= 2
             b & 1 b 1 res |= self.seg[b] res self.seg[b] self.seg self seg b b -= 2 b 2 a >>= 1 a 1 b -= 1 b 1 b >>= 1 b 1 if a == b:
            res |= self.seg[a]
        else:
            res |= (self.seg[a] | self.seg[b])
        
         a == b a b res |= self.seg[a] res self.seg[a] self.seg self seg a res |= (self.seg[a] | self.seg[b]) res self.seg[a] | self.seg[b] self.seg[a] self.seg self seg a self.seg[b] self.seg self seg b return bin(res).count("1") bin(res).count("1") (res).count (res) bin res count "1" self self a a b b def main():
    N = int(readline())
    s = readline().strip()
    seg = SegmentTree(list(s))

    Q = int(readline())
    q = map(str, read().split())
    ans = []
    for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            ans.append(seg.query(int(a)-1, int(b)))
    
    print("\n".join(map(str, ans))) main N = int(readline()) N int(readline()) int readline() readline s = readline().strip() s readline().strip() ().strip () readline strip seg = SegmentTree(list(s)) seg SegmentTree(list(s)) SegmentTree list(s) list s Q = int(readline()) Q int(readline()) int readline() readline q = map(str, read().split()) q map(str, read().split()) map str read().split() ().split () read split ans = [] ans [] for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            ans.append(seg.query(int(a)-1, int(b)))
    
     t a b zip(*[iter(q)]*3) zip *[iter(q)]*3 [iter(q)]*3 [iter(q)] iter(q) iter q 3 if t == "1":
            seg.update(int(a)-1, b)
        else:
            ans.append(seg.query(int(a)-1, int(b)))
    
     t == "1" t "1" seg.update(int(a)-1, b) seg.update seg update int(a)-1 int(a) int a 1 b ans.append(seg.query(int(a)-1, int(b))) ans.append ans append seg.query(int(a)-1, int(b)) seg.query seg query int(a)-1 int(a) int a 1 int(b) int b print("\n".join(map(str, ans))) print "\n".join(map(str, ans)) "\n".join "\n" join map(str, ans) map str ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(readline())
    s = readline().strip()
    seg = SegmentTree(list(s))

    Q = int(readline())
    q = map(str, read().split())
    ans = []
    for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            ans.append(seg.query(int(a)-1, int(b)))
    
    print("\n".join(map(str, ans))) def main():
    N = int(readline())
    s = readline().strip()
    seg = SegmentTree(list(s))

    Q = int(readline())
    q = map(str, read().split())
    ans = []
    for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            ans.append(seg.query(int(a)-1, int(b)))
    
    print("\n".join(map(str, ans))) main readline = sys.stdin.readline sys.stdin.readline readline def string_to_number(a):
    return 1 << (ord(a) - 97) def string_to_number(a):
    return 1 << (ord(a) - 97) string_to_number readlines = sys.stdin.readlines sys.stdin.readlines readlines read = sys.stdin.read sys.stdin.read read class SegmentTree:
    def __init__(self, A):
        self.n = 2**(len(A)-1).bit_length()
        self.identity = 0
        self.seg = [self.identity] * (2 * self.n)
        
        for i, a in enumerate(A):
            self.seg[self.n-1+i] = string_to_number(a)
        for i in range(self.n-2,-1,-1):
            self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2]

            
    def update(self, k, a):
        k += self.n - 1
        self.seg[k] = string_to_number(a)
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2]

            
    def query(self, a, b):
        if b == a:
        	return 1
        a += self.n - 1
        b += self.n - 2
        res = self.identity
        while b - a > 1:
            if not a & 1:
                res |= self.seg[a]
            if b & 1:
                res |= self.seg[b]
                b -= 2
            a >>= 1
            b -= 1
            b >>= 1
        if a == b:
            res |= self.seg[a]
        else:
            res |= (self.seg[a] | self.seg[b])
        
        return bin(res).count("1") class SegmentTree:
    def __init__(self, A):
        self.n = 2**(len(A)-1).bit_length()
        self.identity = 0
        self.seg = [self.identity] * (2 * self.n)
        
        for i, a in enumerate(A):
            self.seg[self.n-1+i] = string_to_number(a)
        for i in range(self.n-2,-1,-1):
            self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2]

            
    def update(self, k, a):
        k += self.n - 1
        self.seg[k] = string_to_number(a)
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2]

            
    def query(self, a, b):
        if b == a:
        	return 1
        a += self.n - 1
        b += self.n - 2
        res = self.identity
        while b - a > 1:
            if not a & 1:
                res |= self.seg[a]
            if b & 1:
                res |= self.seg[b]
                b -= 2
            a >>= 1
            b -= 1
            b >>= 1
        if a == b:
            res |= self.seg[a]
        else:
            res |= (self.seg[a] | self.seg[b])
        
        return bin(res).count("1") SegmentTree
# AC: 577 msec (Python3)
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def string_to_number(a):
    return 1 << (ord(a) - 97)

class SegmentTree:
    def __init__(self, A):
        self.n = 2**(len(A)-1).bit_length()
        self.identity = 0
        self.seg = [self.identity] * (2 * self.n)
        
        for i, a in enumerate(A):
            self.seg[self.n-1+i] = string_to_number(a)
        for i in range(self.n-2,-1,-1):
            self.seg[i] = self.seg[2*i+1] | self.seg[2*i+2]

            
    def update(self, k, a):
        k += self.n - 1
        self.seg[k] = string_to_number(a)
        while k:
            k = (k - 1) // 2
            self.seg[k] = self.seg[k*2+1] | self.seg[k*2+2]

            
    def query(self, a, b):
        if b == a:
        	return 1
        a += self.n - 1
        b += self.n - 2
        res = self.identity
        while b - a > 1:
            if not a & 1:
                res |= self.seg[a]
            if b & 1:
                res |= self.seg[b]
                b -= 2
            a >>= 1
            b -= 1
            b >>= 1
        if a == b:
            res |= self.seg[a]
        else:
            res |= (self.seg[a] | self.seg[b])
        
        return bin(res).count("1")


def main():
    N = int(readline())
    s = readline().strip()
    seg = SegmentTree(list(s))

    Q = int(readline())
    q = map(str, read().split())
    ans = []
    for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            ans.append(seg.query(int(a)-1, int(b)))
    
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()
