import sys
def input(): return sys.stdin.readline().rstrip()


class SegTree:
    X_unit = 0

    def __init__(self, N, X_f=min):
        self.N = N
        self.X = [self.X_unit] * (N + N)
        self.X_f = X_f

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR)


def orr(x, y):
    return x | y


def main():
    N = int(input())
    S = input()
    S = list(map(lambda c: 2**(ord(c) - ord('a')), list(S)))
    Q = int(input())
    seg = SegTree(N, orr)
    seg.build(S)
    for _ in range(Q):
        num, x, y = input().split()
        if num == '1':
            seg.set_val(int(x)-1, 2**(ord(y) - ord('a')))
        else:
            bits=seg.fold(int(x)-1, int(y))
            print(sum(map(int, list(bin(bits))[2:])))


if __name__ == '__main__':
    main() import sys sys def input(): return sys.stdin.readline().rstrip() input class SegTree:
    X_unit = 0

    def __init__(self, N, X_f=min):
        self.N = N
        self.X = [self.X_unit] * (N + N)
        self.X_f = X_f

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR) SegTree X_unit = 0 X_unit 0 def __init__(self, N, X_f=min):
        self.N = N
        self.X = [self.X_unit] * (N + N)
        self.X_f = X_f

     __init__ self.N = N self.N self N N self.X = [self.X_unit] * (N + N) self.X self X [self.X_unit] * (N + N) [self.X_unit] self.X_unit self X_unit N + N N N self.X_f = X_f self.X_f self X_f X_f self self N N X_f=min X_f min def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

     build for i, x in enumerate(seq, self.N):
            self.X[i] = x
         i x enumerate(seq, self.N) enumerate seq self.N self N self.X[i] = x self.X[i] self.X self X i x for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

     i range(self.N - 1, 0, -1) range self.N - 1 self.N self N 1 0 -1 self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1]) self.X[i] self.X self X i self.X_f(self.X[i << 1], self.X[i << 1 | 1]) self.X_f self X_f self.X[i << 1] self.X self X i << 1 i 1 self.X[i << 1 | 1] self.X self X i << 1 | 1 i << 1 i 1 1 self self seq seq def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

     set_val i += self.N i self.N self N self.X[i] = x self.X[i] self.X self X i x while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

     i > 1 i 1 i >>= 1 i 1 self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1]) self.X[i] self.X self X i self.X_f(self.X[i << 1], self.X[i << 1 | 1]) self.X_f self X_f self.X[i << 1] self.X self X i << 1 i 1 self.X[i << 1 | 1] self.X self X i << 1 | 1 i << 1 i 1 1 self self i i x x def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR) fold L += self.N L self.N self N R += self.N R self.N self N vL = self.X_unit vL self.X_unit self X_unit vR = self.X_unit vR self.X_unit self X_unit while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
         L < R L R if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
             L & 1 L 1 vL = self.X_f(vL, self.X[L]) vL self.X_f(vL, self.X[L]) self.X_f self X_f vL self.X[L] self.X self X L L += 1 L 1 if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
             R & 1 R 1 R -= 1 R 1 vR = self.X_f(self.X[R], vR) vR self.X_f(self.X[R], vR) self.X_f self X_f self.X[R] self.X self X R vR L >>= 1 L 1 R >>= 1 R 1 return self.X_f(vL, vR) self.X_f(vL, vR) self.X_f self X_f vL vR self self L L R R def orr(x, y):
    return x | y orr return x | y x | y x y x x y y def main():
    N = int(input())
    S = input()
    S = list(map(lambda c: 2**(ord(c) - ord('a')), list(S)))
    Q = int(input())
    seg = SegTree(N, orr)
    seg.build(S)
    for _ in range(Q):
        num, x, y = input().split()
        if num == '1':
            seg.set_val(int(x)-1, 2**(ord(y) - ord('a')))
        else:
            bits=seg.fold(int(x)-1, int(y))
            print(sum(map(int, list(bin(bits))[2:]))) main N = int(input()) N int(input()) int input() input S = input() S input() input S = list(map(lambda c: 2**(ord(c) - ord('a')), list(S))) S list(map(lambda c: 2**(ord(c) - ord('a')), list(S))) list map(lambda c: 2**(ord(c) - ord('a')), list(S)) map lambda c: 2**(ord(c) - ord('a')) 2**(ord(c) - ord('a')) 2 ord(c) - ord('a') ord(c) ord c ord('a') ord 'a' c list(S) list S Q = int(input()) Q int(input()) int input() input seg = SegTree(N, orr) seg SegTree(N, orr) SegTree N orr seg.build(S) seg.build seg build S for _ in range(Q):
        num, x, y = input().split()
        if num == '1':
            seg.set_val(int(x)-1, 2**(ord(y) - ord('a')))
        else:
            bits=seg.fold(int(x)-1, int(y))
            print(sum(map(int, list(bin(bits))[2:]))) _ range(Q) range Q num, x, y = input().split() num input().split() ().split () input split x y if num == '1':
            seg.set_val(int(x)-1, 2**(ord(y) - ord('a')))
        else:
            bits=seg.fold(int(x)-1, int(y))
            print(sum(map(int, list(bin(bits))[2:]))) num == '1' num '1' seg.set_val(int(x)-1, 2**(ord(y) - ord('a'))) seg.set_val seg set_val int(x)-1 int(x) int x 1 2**(ord(y) - ord('a')) 2 ord(y) - ord('a') ord(y) ord y ord('a') ord 'a' bits=seg.fold(int(x)-1, int(y)) bits seg.fold(int(x)-1, int(y)) seg.fold seg fold int(x)-1 int(x) int x 1 int(y) int y print(sum(map(int, list(bin(bits))[2:]))) print sum(map(int, list(bin(bits))[2:])) sum map(int, list(bin(bits))[2:]) map int list(bin(bits))[2:] (bin(bits)) list bin(bits) bin bits 2: 2 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def orr(x, y):
    return x | y def orr(x, y):
    return x | y orr def input(): return sys.stdin.readline().rstrip() def input(): return sys.stdin.readline().rstrip() input class SegTree:
    X_unit = 0

    def __init__(self, N, X_f=min):
        self.N = N
        self.X = [self.X_unit] * (N + N)
        self.X_f = X_f

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR) class SegTree:
    X_unit = 0

    def __init__(self, N, X_f=min):
        self.N = N
        self.X = [self.X_unit] * (N + N)
        self.X_f = X_f

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR) SegTree def main():
    N = int(input())
    S = input()
    S = list(map(lambda c: 2**(ord(c) - ord('a')), list(S)))
    Q = int(input())
    seg = SegTree(N, orr)
    seg.build(S)
    for _ in range(Q):
        num, x, y = input().split()
        if num == '1':
            seg.set_val(int(x)-1, 2**(ord(y) - ord('a')))
        else:
            bits=seg.fold(int(x)-1, int(y))
            print(sum(map(int, list(bin(bits))[2:]))) def main():
    N = int(input())
    S = input()
    S = list(map(lambda c: 2**(ord(c) - ord('a')), list(S)))
    Q = int(input())
    seg = SegTree(N, orr)
    seg.build(S)
    for _ in range(Q):
        num, x, y = input().split()
        if num == '1':
            seg.set_val(int(x)-1, 2**(ord(y) - ord('a')))
        else:
            bits=seg.fold(int(x)-1, int(y))
            print(sum(map(int, list(bin(bits))[2:]))) main
import sys
def input(): return sys.stdin.readline().rstrip()


class SegTree:
    X_unit = 0

    def __init__(self, N, X_f=min):
        self.N = N
        self.X = [self.X_unit] * (N + N)
        self.X_f = X_f

    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x
        for i in range(self.N - 1, 0, -1):
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

    def fold(self, L, R):
        L += self.N
        R += self.N
        vL = self.X_unit
        vR = self.X_unit
        while L < R:
            if L & 1:
                vL = self.X_f(vL, self.X[L])
                L += 1
            if R & 1:
                R -= 1
                vR = self.X_f(self.X[R], vR)
            L >>= 1
            R >>= 1
        return self.X_f(vL, vR)


def orr(x, y):
    return x | y


def main():
    N = int(input())
    S = input()
    S = list(map(lambda c: 2**(ord(c) - ord('a')), list(S)))
    Q = int(input())
    seg = SegTree(N, orr)
    seg.build(S)
    for _ in range(Q):
        num, x, y = input().split()
        if num == '1':
            seg.set_val(int(x)-1, 2**(ord(y) - ord('a')))
        else:
            bits=seg.fold(int(x)-1, int(y))
            print(sum(map(int, list(bin(bits))[2:])))


if __name__ == '__main__':
    main()