def main():
    n = int(input())
    s = input()
    Q = int(input())
    t = [input().split() for _ in range(Q)]

    d = [0] * n + [1 << ord(c) - 97 for c in s]
    for i in range(n - 1, 0, -1):
        d[i] = d[i + i] | d[i - ~i]
    for q, a, b in t:
        i, s = int(a) + n - 1, 0
        if q < "2":
            d[i] = 1 << ord(b) - 97
            while i > 1:
                i //= 2
                d[i] = d[i + i] | d[i - ~i]
        else:
            j = int(b) + n
            while i < j:
                if i & 1:
                    s |= d[i]
                    i += 1
                if j & 1:
                    j -= 1
                    s |= d[j]
                i //= 2
                j //= 2
            print(bin(s).count("1"))


main() def main():
    n = int(input())
    s = input()
    Q = int(input())
    t = [input().split() for _ in range(Q)]

    d = [0] * n + [1 << ord(c) - 97 for c in s]
    for i in range(n - 1, 0, -1):
        d[i] = d[i + i] | d[i - ~i]
    for q, a, b in t:
        i, s = int(a) + n - 1, 0
        if q < "2":
            d[i] = 1 << ord(b) - 97
            while i > 1:
                i //= 2
                d[i] = d[i + i] | d[i - ~i]
        else:
            j = int(b) + n
            while i < j:
                if i & 1:
                    s |= d[i]
                    i += 1
                if j & 1:
                    j -= 1
                    s |= d[j]
                i //= 2
                j //= 2
            print(bin(s).count("1")) main n = int(input()) n int(input()) int input() input s = input() s input() input Q = int(input()) Q int(input()) int input() input input().split() for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) input().split() ().split () input split t = [input().split() for _ in range(Q)] t [input().split() for _ in range(Q)] 1 << ord(c) - 97 for c in s for c in s c s for c in s 1 << ord(c) - 97 1 ord(c) - 97 ord(c) ord c 97 d = [0] * n + [1 << ord(c) - 97 for c in s] d [0] * n + [1 << ord(c) - 97 for c in s] [0] * n [0] 0 n [1 << ord(c) - 97 for c in s] for i in range(n - 1, 0, -1):
        d[i] = d[i + i] | d[i - ~i]
     i range(n - 1, 0, -1) range n - 1 n 1 0 -1 d[i] = d[i + i] | d[i - ~i] d[i] d i d[i + i] | d[i - ~i] d[i + i] d i + i i i d[i - ~i] d i - ~i i ~i i for q, a, b in t:
        i, s = int(a) + n - 1, 0
        if q < "2":
            d[i] = 1 << ord(b) - 97
            while i > 1:
                i //= 2
                d[i] = d[i + i] | d[i - ~i]
        else:
            j = int(b) + n
            while i < j:
                if i & 1:
                    s |= d[i]
                    i += 1
                if j & 1:
                    j -= 1
                    s |= d[j]
                i //= 2
                j //= 2
            print(bin(s).count("1")) q a b t i, s = int(a) + n - 1, 0 i int(a) + n - 1 int(a) + n int(a) int a n 1 s 0 if q < "2":
            d[i] = 1 << ord(b) - 97
            while i > 1:
                i //= 2
                d[i] = d[i + i] | d[i - ~i]
        else:
            j = int(b) + n
            while i < j:
                if i & 1:
                    s |= d[i]
                    i += 1
                if j & 1:
                    j -= 1
                    s |= d[j]
                i //= 2
                j //= 2
            print(bin(s).count("1")) q < "2" q "2" d[i] = 1 << ord(b) - 97 d[i] d i 1 << ord(b) - 97 1 ord(b) - 97 ord(b) ord b 97 while i > 1:
                i //= 2
                d[i] = d[i + i] | d[i - ~i]
         i > 1 i 1 i //= 2 i 2 d[i] = d[i + i] | d[i - ~i] d[i] d i d[i + i] | d[i - ~i] d[i + i] d i + i i i d[i - ~i] d i - ~i i ~i i j = int(b) + n j int(b) + n int(b) int b n while i < j:
                if i & 1:
                    s |= d[i]
                    i += 1
                if j & 1:
                    j -= 1
                    s |= d[j]
                i //= 2
                j //= 2
             i < j i j if i & 1:
                    s |= d[i]
                    i += 1
                 i & 1 i 1 s |= d[i] s d[i] d i i += 1 i 1 if j & 1:
                    j -= 1
                    s |= d[j]
                 j & 1 j 1 j -= 1 j 1 s |= d[j] s d[j] d j i //= 2 i 2 j //= 2 j 2 print(bin(s).count("1")) print bin(s).count("1") (s).count (s) bin s count "1" main() main def main():
    n = int(input())
    s = input()
    Q = int(input())
    t = [input().split() for _ in range(Q)]

    d = [0] * n + [1 << ord(c) - 97 for c in s]
    for i in range(n - 1, 0, -1):
        d[i] = d[i + i] | d[i - ~i]
    for q, a, b in t:
        i, s = int(a) + n - 1, 0
        if q < "2":
            d[i] = 1 << ord(b) - 97
            while i > 1:
                i //= 2
                d[i] = d[i + i] | d[i - ~i]
        else:
            j = int(b) + n
            while i < j:
                if i & 1:
                    s |= d[i]
                    i += 1
                if j & 1:
                    j -= 1
                    s |= d[j]
                i //= 2
                j //= 2
            print(bin(s).count("1")) def main():
    n = int(input())
    s = input()
    Q = int(input())
    t = [input().split() for _ in range(Q)]

    d = [0] * n + [1 << ord(c) - 97 for c in s]
    for i in range(n - 1, 0, -1):
        d[i] = d[i + i] | d[i - ~i]
    for q, a, b in t:
        i, s = int(a) + n - 1, 0
        if q < "2":
            d[i] = 1 << ord(b) - 97
            while i > 1:
                i //= 2
                d[i] = d[i + i] | d[i - ~i]
        else:
            j = int(b) + n
            while i < j:
                if i & 1:
                    s |= d[i]
                    i += 1
                if j & 1:
                    j -= 1
                    s |= d[j]
                i //= 2
                j //= 2
            print(bin(s).count("1")) main
def main():
    n = int(input())
    s = input()
    Q = int(input())
    t = [input().split() for _ in range(Q)]

    d = [0] * n + [1 << ord(c) - 97 for c in s]
    for i in range(n - 1, 0, -1):
        d[i] = d[i + i] | d[i - ~i]
    for q, a, b in t:
        i, s = int(a) + n - 1, 0
        if q < "2":
            d[i] = 1 << ord(b) - 97
            while i > 1:
                i //= 2
                d[i] = d[i + i] | d[i - ~i]
        else:
            j = int(b) + n
            while i < j:
                if i & 1:
                    s |= d[i]
                    i += 1
                if j & 1:
                    j -= 1
                    s |= d[j]
                i //= 2
                j //= 2
            print(bin(s).count("1"))


main()
