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:
    """
    セグ木は 1-indexed
    """
    def __init__(self, n, initial=0):
        self.offset = 2**(n-1).bit_length()
        self.initial = initial
        self.seg = [self.initial] * (2 * self.offset)


    def build(self, A):
        """
        A: 処理したい配列
        """
        for i, a in enumerate(A, start=self.offset):
            self.seg[i] = string_to_number(a)
        for i in range(self.offset-1,0,-1):
            self.seg[i] = self.seg[i<<1] | self.seg[(i<<1)+1]

            
    def update(self, k, a):
        k += self.offset
        self.seg[k] = string_to_number(a)
        while k:
            k >>= 1
            self.seg[k] = self.seg[k<<1] | self.seg[(k<<1)+1]

            
    def query(self, a, b):
        a += self.offset
        b += self.offset
        res = self.initial
        while a < b:
            if a & 1:
                res |= self.seg[a]
                a += 1
            if b & 1:
                res |= self.seg[b-1]
            a >>= 1
            b >>= 1
        
        return bin(res).count("1")


def main():
    N,s,Q,*q = read().split()
    seg = SegmentTree(int(N))
    seg.build(s)
    #print(seg.seg)

    for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            print(seg.query(int(a)-1, int(b)))


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:
    """
    セグ木は 1-indexed
    """
    def __init__(self, n, initial=0):
        self.offset = 2**(n-1).bit_length()
        self.initial = initial
        self.seg = [self.initial] * (2 * self.offset)


    def build(self, A):
        """
        A: 処理したい配列
        """
        for i, a in enumerate(A, start=self.offset):
            self.seg[i] = string_to_number(a)
        for i in range(self.offset-1,0,-1):
            self.seg[i] = self.seg[i<<1] | self.seg[(i<<1)+1]

            
    def update(self, k, a):
        k += self.offset
        self.seg[k] = string_to_number(a)
        while k:
            k >>= 1
            self.seg[k] = self.seg[k<<1] | self.seg[(k<<1)+1]

            
    def query(self, a, b):
        a += self.offset
        b += self.offset
        res = self.initial
        while a < b:
            if a & 1:
                res |= self.seg[a]
                a += 1
            if b & 1:
                res |= self.seg[b-1]
            a >>= 1
            b >>= 1
        
        return bin(res).count("1") SegmentTree """
    セグ木は 1-indexed
    """ def __init__(self, n, initial=0):
        self.offset = 2**(n-1).bit_length()
        self.initial = initial
        self.seg = [self.initial] * (2 * self.offset)


     __init__ self.offset = 2**(n-1).bit_length() self.offset self offset 2**(n-1).bit_length() 2 (n-1).bit_length() n-1).bit_length n-1 n 1 bit_length self.initial = initial self.initial self initial initial self.seg = [self.initial] * (2 * self.offset) self.seg self seg [self.initial] * (2 * self.offset) [self.initial] self.initial self initial 2 * self.offset 2 self.offset self offset self self n n initial=0 initial 0 def build(self, A):
        """
        A: 処理したい配列
        """
        for i, a in enumerate(A, start=self.offset):
            self.seg[i] = string_to_number(a)
        for i in range(self.offset-1,0,-1):
            self.seg[i] = self.seg[i<<1] | self.seg[(i<<1)+1]

            
     build """
        A: 処理したい配列
        """ for i, a in enumerate(A, start=self.offset):
            self.seg[i] = string_to_number(a)
         i a enumerate(A, start=self.offset) enumerate A start=self.offset start self.offset self offset self.seg[i] = string_to_number(a) self.seg[i] self.seg self seg i string_to_number(a) string_to_number a for i in range(self.offset-1,0,-1):
            self.seg[i] = self.seg[i<<1] | self.seg[(i<<1)+1]

            
     i range(self.offset-1,0,-1) range self.offset-1 self.offset self offset 1 0 -1 self.seg[i] = self.seg[i<<1] | self.seg[(i<<1)+1] self.seg[i] self.seg self seg i self.seg[i<<1] | self.seg[(i<<1)+1] self.seg[i<<1] self.seg self seg i<<1 i 1 self.seg[(i<<1)+1] self.seg self seg (i<<1)+1 i<<1 i 1 1 self self A A def update(self, k, a):
        k += self.offset
        self.seg[k] = string_to_number(a)
        while k:
            k >>= 1
            self.seg[k] = self.seg[k<<1] | self.seg[(k<<1)+1]

            
     update k += self.offset k self.offset self offset 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 >>= 1
            self.seg[k] = self.seg[k<<1] | self.seg[(k<<1)+1]

            
     k k >>= 1 k 1 self.seg[k] = self.seg[k<<1] | self.seg[(k<<1)+1] self.seg[k] self.seg self seg k self.seg[k<<1] | self.seg[(k<<1)+1] self.seg[k<<1] self.seg self seg k<<1 k 1 self.seg[(k<<1)+1] self.seg self seg (k<<1)+1 k<<1 k 1 1 self self k k a a def query(self, a, b):
        a += self.offset
        b += self.offset
        res = self.initial
        while a < b:
            if a & 1:
                res |= self.seg[a]
                a += 1
            if b & 1:
                res |= self.seg[b-1]
            a >>= 1
            b >>= 1
        
        return bin(res).count("1") query a += self.offset a self.offset self offset b += self.offset b self.offset self offset res = self.initial res self.initial self initial while a < b:
            if a & 1:
                res |= self.seg[a]
                a += 1
            if b & 1:
                res |= self.seg[b-1]
            a >>= 1
            b >>= 1
        
         a < b a b if a & 1:
                res |= self.seg[a]
                a += 1
             a & 1 a 1 res |= self.seg[a] res self.seg[a] self.seg self seg a a += 1 a 1 if b & 1:
                res |= self.seg[b-1]
             b & 1 b 1 res |= self.seg[b-1] res self.seg[b-1] self.seg self seg b-1 b 1 a >>= 1 a 1 b >>= 1 b 1 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,s,Q,*q = read().split()
    seg = SegmentTree(int(N))
    seg.build(s)
    #print(seg.seg)

    for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            print(seg.query(int(a)-1, int(b))) main N,s,Q,*q = read().split() N read().split() ().split () read split s Q *q q seg = SegmentTree(int(N)) seg SegmentTree(int(N)) SegmentTree int(N) int N seg.build(s) seg.build seg build s for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            print(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:
            print(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 print(seg.query(int(a)-1, int(b))) print seg.query(int(a)-1, int(b)) seg.query seg query int(a)-1 int(a) int a 1 int(b) int b if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main class SegmentTree:
    """
    セグ木は 1-indexed
    """
    def __init__(self, n, initial=0):
        self.offset = 2**(n-1).bit_length()
        self.initial = initial
        self.seg = [self.initial] * (2 * self.offset)


    def build(self, A):
        """
        A: 処理したい配列
        """
        for i, a in enumerate(A, start=self.offset):
            self.seg[i] = string_to_number(a)
        for i in range(self.offset-1,0,-1):
            self.seg[i] = self.seg[i<<1] | self.seg[(i<<1)+1]

            
    def update(self, k, a):
        k += self.offset
        self.seg[k] = string_to_number(a)
        while k:
            k >>= 1
            self.seg[k] = self.seg[k<<1] | self.seg[(k<<1)+1]

            
    def query(self, a, b):
        a += self.offset
        b += self.offset
        res = self.initial
        while a < b:
            if a & 1:
                res |= self.seg[a]
                a += 1
            if b & 1:
                res |= self.seg[b-1]
            a >>= 1
            b >>= 1
        
        return bin(res).count("1") class SegmentTree:
    """
    セグ木は 1-indexed
    """
    def __init__(self, n, initial=0):
        self.offset = 2**(n-1).bit_length()
        self.initial = initial
        self.seg = [self.initial] * (2 * self.offset)


    def build(self, A):
        """
        A: 処理したい配列
        """
        for i, a in enumerate(A, start=self.offset):
            self.seg[i] = string_to_number(a)
        for i in range(self.offset-1,0,-1):
            self.seg[i] = self.seg[i<<1] | self.seg[(i<<1)+1]

            
    def update(self, k, a):
        k += self.offset
        self.seg[k] = string_to_number(a)
        while k:
            k >>= 1
            self.seg[k] = self.seg[k<<1] | self.seg[(k<<1)+1]

            
    def query(self, a, b):
        a += self.offset
        b += self.offset
        res = self.initial
        while a < b:
            if a & 1:
                res |= self.seg[a]
                a += 1
            if b & 1:
                res |= self.seg[b-1]
            a >>= 1
            b >>= 1
        
        return bin(res).count("1") SegmentTree def string_to_number(a):
    return 1 << (ord(a) - 97) def string_to_number(a):
    return 1 << (ord(a) - 97) string_to_number readline = sys.stdin.readline sys.stdin.readline readline def main():
    N,s,Q,*q = read().split()
    seg = SegmentTree(int(N))
    seg.build(s)
    #print(seg.seg)

    for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            print(seg.query(int(a)-1, int(b))) def main():
    N,s,Q,*q = read().split()
    seg = SegmentTree(int(N))
    seg.build(s)
    #print(seg.seg)

    for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            print(seg.query(int(a)-1, int(b))) main read = sys.stdin.read sys.stdin.read read readlines = sys.stdin.readlines sys.stdin.readlines readlines
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:
    """
    セグ木は 1-indexed
    """
    def __init__(self, n, initial=0):
        self.offset = 2**(n-1).bit_length()
        self.initial = initial
        self.seg = [self.initial] * (2 * self.offset)


    def build(self, A):
        """
        A: 処理したい配列
        """
        for i, a in enumerate(A, start=self.offset):
            self.seg[i] = string_to_number(a)
        for i in range(self.offset-1,0,-1):
            self.seg[i] = self.seg[i<<1] | self.seg[(i<<1)+1]

            
    def update(self, k, a):
        k += self.offset
        self.seg[k] = string_to_number(a)
        while k:
            k >>= 1
            self.seg[k] = self.seg[k<<1] | self.seg[(k<<1)+1]

            
    def query(self, a, b):
        a += self.offset
        b += self.offset
        res = self.initial
        while a < b:
            if a & 1:
                res |= self.seg[a]
                a += 1
            if b & 1:
                res |= self.seg[b-1]
            a >>= 1
            b >>= 1
        
        return bin(res).count("1")


def main():
    N,s,Q,*q = read().split()
    seg = SegmentTree(int(N))
    seg.build(s)
    #print(seg.seg)

    for t, a, b in zip(*[iter(q)]*3):
        if t == "1":
            seg.update(int(a)-1, b)
        else:
            print(seg.query(int(a)-1, int(b)))


if __name__ == "__main__":
    main()
