class SegTree:
    def __init__(self, a, func):
        self.n = 2**(len(a) - 1).bit_length()
        self.f = func
        self.d = [0] * (2 * self.n - 1)
        self.d[self.n - 1:self.n - 1 + len(a)] = a
        for i in reversed(range(self.n - 1)):
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def update(self, i, v):
        i += self.n - 1
        self.d[i] = v
        while i:
            i = (i - 1) // 2
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def query(self, l, r):
        assert l <= r
        l += self.n
        r += self.n
        s = self.d[l - 1]
        while l < r:
            if l & 1:
                s = self.f(s, self.d[l - 1])
                l += 1
            if r & 1:
                r -= 1
                s = self.f(s, self.d[r - 1])
            l //= 2
            r //= 2
        return s

def main():
    N = int(input())
    S = [1 << (ord(s) - 97) for s in input()]
    T = SegTree(S, lambda x, y: x | y)

    Q = int(input())
    for _ in range(Q):
        t, a, b = input().split()
        if t == '1':
            T.update(int(a) - 1, 1 << (ord(b) - 97))
        else:
            print(bin(T.query(int(a) - 1, int(b))).count('1'))

main() class SegTree:
    def __init__(self, a, func):
        self.n = 2**(len(a) - 1).bit_length()
        self.f = func
        self.d = [0] * (2 * self.n - 1)
        self.d[self.n - 1:self.n - 1 + len(a)] = a
        for i in reversed(range(self.n - 1)):
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def update(self, i, v):
        i += self.n - 1
        self.d[i] = v
        while i:
            i = (i - 1) // 2
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def query(self, l, r):
        assert l <= r
        l += self.n
        r += self.n
        s = self.d[l - 1]
        while l < r:
            if l & 1:
                s = self.f(s, self.d[l - 1])
                l += 1
            if r & 1:
                r -= 1
                s = self.f(s, self.d[r - 1])
            l //= 2
            r //= 2
        return s SegTree def __init__(self, a, func):
        self.n = 2**(len(a) - 1).bit_length()
        self.f = func
        self.d = [0] * (2 * self.n - 1)
        self.d[self.n - 1:self.n - 1 + len(a)] = a
        for i in reversed(range(self.n - 1)):
            self.d[i] = self.f(self.d[2 * i + 1], self.d[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.f = func self.f self f func self.d = [0] * (2 * self.n - 1) self.d self d [0] * (2 * self.n - 1) [0] 0 2 * self.n - 1 2 * self.n 2 self.n self n 1 self.d[self.n - 1:self.n - 1 + len(a)] = a self.d[self.n - 1:self.n - 1 + len(a)] self.d self d self.n - 1:self.n - 1 + len(a) self.n - 1 self.n self n 1 self.n - 1 + len(a) self.n - 1 self.n self n 1 len(a) len a a for i in reversed(range(self.n - 1)):
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

     i reversed(range(self.n - 1)) reversed range(self.n - 1) range self.n - 1 self.n self n 1 self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2]) self.d[i] self.d self d i self.f(self.d[2 * i + 1], self.d[2 * i + 2]) self.f self f self.d[2 * i + 1] self.d self d 2 * i + 1 2 * i 2 i 1 self.d[2 * i + 2] self.d self d 2 * i + 2 2 * i 2 i 2 self self a a func func def update(self, i, v):
        i += self.n - 1
        self.d[i] = v
        while i:
            i = (i - 1) // 2
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

     update i += self.n - 1 i self.n - 1 self.n self n 1 self.d[i] = v self.d[i] self.d self d i v while i:
            i = (i - 1) // 2
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

     i i = (i - 1) // 2 i (i - 1) // 2 i - 1 i 1 2 self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2]) self.d[i] self.d self d i self.f(self.d[2 * i + 1], self.d[2 * i + 2]) self.f self f self.d[2 * i + 1] self.d self d 2 * i + 1 2 * i 2 i 1 self.d[2 * i + 2] self.d self d 2 * i + 2 2 * i 2 i 2 self self i i v v def query(self, l, r):
        assert l <= r
        l += self.n
        r += self.n
        s = self.d[l - 1]
        while l < r:
            if l & 1:
                s = self.f(s, self.d[l - 1])
                l += 1
            if r & 1:
                r -= 1
                s = self.f(s, self.d[r - 1])
            l //= 2
            r //= 2
        return s query assert l <= r l <= r l r l += self.n l self.n self n r += self.n r self.n self n s = self.d[l - 1] s self.d[l - 1] self.d self d l - 1 l 1 while l < r:
            if l & 1:
                s = self.f(s, self.d[l - 1])
                l += 1
            if r & 1:
                r -= 1
                s = self.f(s, self.d[r - 1])
            l //= 2
            r //= 2
         l < r l r if l & 1:
                s = self.f(s, self.d[l - 1])
                l += 1
             l & 1 l 1 s = self.f(s, self.d[l - 1]) s self.f(s, self.d[l - 1]) self.f self f s self.d[l - 1] self.d self d l - 1 l 1 l += 1 l 1 if r & 1:
                r -= 1
                s = self.f(s, self.d[r - 1])
             r & 1 r 1 r -= 1 r 1 s = self.f(s, self.d[r - 1]) s self.f(s, self.d[r - 1]) self.f self f s self.d[r - 1] self.d self d r - 1 r 1 l //= 2 l 2 r //= 2 r 2 return s s self self l l r r def main():
    N = int(input())
    S = [1 << (ord(s) - 97) for s in input()]
    T = SegTree(S, lambda x, y: x | y)

    Q = int(input())
    for _ in range(Q):
        t, a, b = input().split()
        if t == '1':
            T.update(int(a) - 1, 1 << (ord(b) - 97))
        else:
            print(bin(T.query(int(a) - 1, int(b))).count('1')) main N = int(input()) N int(input()) int input() input 1 << (ord(s) - 97) for s in input() for s in input() s input() input for s in input() 1 << (ord(s) - 97) 1 ord(s) - 97 ord(s) ord s 97 S = [1 << (ord(s) - 97) for s in input()] S [1 << (ord(s) - 97) for s in input()] T = SegTree(S, lambda x, y: x | y) T SegTree(S, lambda x, y: x | y) SegTree S lambda x, y: x | y x | y x y x y Q = int(input()) Q int(input()) int input() input for _ in range(Q):
        t, a, b = input().split()
        if t == '1':
            T.update(int(a) - 1, 1 << (ord(b) - 97))
        else:
            print(bin(T.query(int(a) - 1, int(b))).count('1')) _ range(Q) range Q t, a, b = input().split() t input().split() ().split () input split a b if t == '1':
            T.update(int(a) - 1, 1 << (ord(b) - 97))
        else:
            print(bin(T.query(int(a) - 1, int(b))).count('1')) t == '1' t '1' T.update(int(a) - 1, 1 << (ord(b) - 97)) T.update T update int(a) - 1 int(a) int a 1 1 << (ord(b) - 97) 1 ord(b) - 97 ord(b) ord b 97 print(bin(T.query(int(a) - 1, int(b))).count('1')) print bin(T.query(int(a) - 1, int(b))).count('1') (T.query(int(a) - 1, int(b))).count (T.query(int(a) - 1, int(b))) bin T.query(int(a) - 1, int(b)) T.query T query int(a) - 1 int(a) int a 1 int(b) int b count '1' main() main class SegTree:
    def __init__(self, a, func):
        self.n = 2**(len(a) - 1).bit_length()
        self.f = func
        self.d = [0] * (2 * self.n - 1)
        self.d[self.n - 1:self.n - 1 + len(a)] = a
        for i in reversed(range(self.n - 1)):
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def update(self, i, v):
        i += self.n - 1
        self.d[i] = v
        while i:
            i = (i - 1) // 2
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def query(self, l, r):
        assert l <= r
        l += self.n
        r += self.n
        s = self.d[l - 1]
        while l < r:
            if l & 1:
                s = self.f(s, self.d[l - 1])
                l += 1
            if r & 1:
                r -= 1
                s = self.f(s, self.d[r - 1])
            l //= 2
            r //= 2
        return s class SegTree:
    def __init__(self, a, func):
        self.n = 2**(len(a) - 1).bit_length()
        self.f = func
        self.d = [0] * (2 * self.n - 1)
        self.d[self.n - 1:self.n - 1 + len(a)] = a
        for i in reversed(range(self.n - 1)):
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def update(self, i, v):
        i += self.n - 1
        self.d[i] = v
        while i:
            i = (i - 1) // 2
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def query(self, l, r):
        assert l <= r
        l += self.n
        r += self.n
        s = self.d[l - 1]
        while l < r:
            if l & 1:
                s = self.f(s, self.d[l - 1])
                l += 1
            if r & 1:
                r -= 1
                s = self.f(s, self.d[r - 1])
            l //= 2
            r //= 2
        return s SegTree def main():
    N = int(input())
    S = [1 << (ord(s) - 97) for s in input()]
    T = SegTree(S, lambda x, y: x | y)

    Q = int(input())
    for _ in range(Q):
        t, a, b = input().split()
        if t == '1':
            T.update(int(a) - 1, 1 << (ord(b) - 97))
        else:
            print(bin(T.query(int(a) - 1, int(b))).count('1')) def main():
    N = int(input())
    S = [1 << (ord(s) - 97) for s in input()]
    T = SegTree(S, lambda x, y: x | y)

    Q = int(input())
    for _ in range(Q):
        t, a, b = input().split()
        if t == '1':
            T.update(int(a) - 1, 1 << (ord(b) - 97))
        else:
            print(bin(T.query(int(a) - 1, int(b))).count('1')) main
class SegTree:
    def __init__(self, a, func):
        self.n = 2**(len(a) - 1).bit_length()
        self.f = func
        self.d = [0] * (2 * self.n - 1)
        self.d[self.n - 1:self.n - 1 + len(a)] = a
        for i in reversed(range(self.n - 1)):
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def update(self, i, v):
        i += self.n - 1
        self.d[i] = v
        while i:
            i = (i - 1) // 2
            self.d[i] = self.f(self.d[2 * i + 1], self.d[2 * i + 2])

    def query(self, l, r):
        assert l <= r
        l += self.n
        r += self.n
        s = self.d[l - 1]
        while l < r:
            if l & 1:
                s = self.f(s, self.d[l - 1])
                l += 1
            if r & 1:
                r -= 1
                s = self.f(s, self.d[r - 1])
            l //= 2
            r //= 2
        return s

def main():
    N = int(input())
    S = [1 << (ord(s) - 97) for s in input()]
    T = SegTree(S, lambda x, y: x | y)

    Q = int(input())
    for _ in range(Q):
        t, a, b = input().split()
        if t == '1':
            T.update(int(a) - 1, 1 << (ord(b) - 97))
        else:
            print(bin(T.query(int(a) - 1, int(b))).count('1'))

main()
