#!python3

import sys

input = sys.stdin.readline

def resolve():
    N = int(input())
    S = list(input())
    Q = int(input())

    c0 = ord('a')
    smap = [1<<(i-c0) for i in range(c0, ord('z')+1)]

    T = [0]*N + [smap[ord(S[i])-c0] for i in range(N)]

    for i in range(N-1, 0, -1):
        i2 = i << 1
        T[i] = T[i2] | T[i2|1]

    ans = []
    #print(T)
    for cmd, i, j in zip(*[iter(sys.stdin.read().split())]*3):
        i = int(i) - 1
        if cmd == "1":
            if S[i] == j:
                continue

            S[i] = j
            i0 = N + i
            T[i0] = smap[ord(j)-c0]
            while i0 > 1:
                i0 = i0 >> 1
                T[i0] = T[i0+i0] | T[i0-~i0]
        elif cmd == "2":
            i += N
            j = int(j) + N

            d1 = 0
            while i < j:
                if i & 1:
                    d1 |= T[i]
                    i += 1
                if j & 1:
                    j -= 1
                    d1 |= T[j]

                i >>= 1; j >>=1

            ans.append(bin(d1).count('1'))

    print(*ans, sep="\n")

if __name__ == "__main__":
    resolve() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def resolve():
    N = int(input())
    S = list(input())
    Q = int(input())

    c0 = ord('a')
    smap = [1<<(i-c0) for i in range(c0, ord('z')+1)]

    T = [0]*N + [smap[ord(S[i])-c0] for i in range(N)]

    for i in range(N-1, 0, -1):
        i2 = i << 1
        T[i] = T[i2] | T[i2|1]

    ans = []
    #print(T)
    for cmd, i, j in zip(*[iter(sys.stdin.read().split())]*3):
        i = int(i) - 1
        if cmd == "1":
            if S[i] == j:
                continue

            S[i] = j
            i0 = N + i
            T[i0] = smap[ord(j)-c0]
            while i0 > 1:
                i0 = i0 >> 1
                T[i0] = T[i0+i0] | T[i0-~i0]
        elif cmd == "2":
            i += N
            j = int(j) + N

            d1 = 0
            while i < j:
                if i & 1:
                    d1 |= T[i]
                    i += 1
                if j & 1:
                    j -= 1
                    d1 |= T[j]

                i >>= 1; j >>=1

            ans.append(bin(d1).count('1'))

    print(*ans, sep="\n") resolve N = int(input()) N int(input()) int input() input S = list(input()) S list(input()) list input() input Q = int(input()) Q int(input()) int input() input c0 = ord('a') c0 ord('a') ord 'a' 1<<(i-c0) for i in range(c0, ord('z')+1) for i in range(c0, ord('z')+1) i range(c0, ord('z')+1) range c0 ord('z')+1 ord('z') ord 'z' 1 for i in range(c0, ord('z')+1) 1<<(i-c0) 1 i-c0 i c0 smap = [1<<(i-c0) for i in range(c0, ord('z')+1)] smap [1<<(i-c0) for i in range(c0, ord('z')+1)] smap[ord(S[i])-c0] for i in range(N) for i in range(N) i range(N) range N for i in range(N) smap[ord(S[i])-c0] smap ord(S[i])-c0 ord(S[i]) ord S[i] S i c0 T = [0]*N + [smap[ord(S[i])-c0] for i in range(N)] T [0]*N + [smap[ord(S[i])-c0] for i in range(N)] [0]*N [0] 0 N [smap[ord(S[i])-c0] for i in range(N)] for i in range(N-1, 0, -1):
        i2 = i << 1
        T[i] = T[i2] | T[i2|1]

     i range(N-1, 0, -1) range N-1 N 1 0 -1 i2 = i << 1 i2 i << 1 i 1 T[i] = T[i2] | T[i2|1] T[i] T i T[i2] | T[i2|1] T[i2] T i2 T[i2|1] T i2|1 i2 1 ans = [] ans [] for cmd, i, j in zip(*[iter(sys.stdin.read().split())]*3):
        i = int(i) - 1
        if cmd == "1":
            if S[i] == j:
                continue

            S[i] = j
            i0 = N + i
            T[i0] = smap[ord(j)-c0]
            while i0 > 1:
                i0 = i0 >> 1
                T[i0] = T[i0+i0] | T[i0-~i0]
        elif cmd == "2":
            i += N
            j = int(j) + N

            d1 = 0
            while i < j:
                if i & 1:
                    d1 |= T[i]
                    i += 1
                if j & 1:
                    j -= 1
                    d1 |= T[j]

                i >>= 1; j >>=1

            ans.append(bin(d1).count('1'))

     cmd i j zip(*[iter(sys.stdin.read().split())]*3) zip *[iter(sys.stdin.read().split())]*3 [iter(sys.stdin.read().split())]*3 [iter(sys.stdin.read().split())] iter(sys.stdin.read().split()) iter sys.stdin.read().split() sys.stdin.read().split sys.stdin.read() sys.stdin.read sys.stdin sys stdin read split 3 i = int(i) - 1 i int(i) - 1 int(i) int i 1 if cmd == "1":
            if S[i] == j:
                continue

            S[i] = j
            i0 = N + i
            T[i0] = smap[ord(j)-c0]
            while i0 > 1:
                i0 = i0 >> 1
                T[i0] = T[i0+i0] | T[i0-~i0]
        elif cmd == "2":
            i += N
            j = int(j) + N

            d1 = 0
            while i < j:
                if i & 1:
                    d1 |= T[i]
                    i += 1
                if j & 1:
                    j -= 1
                    d1 |= T[j]

                i >>= 1; j >>=1

            ans.append(bin(d1).count('1'))

     cmd == "1" cmd "1" if S[i] == j:
                continue

             S[i] == j S[i] S i j continue S[i] = j S[i] S i j i0 = N + i i0 N + i N i T[i0] = smap[ord(j)-c0] T[i0] T i0 smap[ord(j)-c0] smap ord(j)-c0 ord(j) ord j c0 while i0 > 1:
                i0 = i0 >> 1
                T[i0] = T[i0+i0] | T[i0-~i0]
         i0 > 1 i0 1 i0 = i0 >> 1 i0 i0 >> 1 i0 1 T[i0] = T[i0+i0] | T[i0-~i0] T[i0] T i0 T[i0+i0] | T[i0-~i0] T[i0+i0] T i0+i0 i0 i0 T[i0-~i0] T i0-~i0 i0 ~i0 i0 elif cmd == "2":
            i += N
            j = int(j) + N

            d1 = 0
            while i < j:
                if i & 1:
                    d1 |= T[i]
                    i += 1
                if j & 1:
                    j -= 1
                    d1 |= T[j]

                i >>= 1; j >>=1

            ans.append(bin(d1).count('1'))

     cmd == "2" cmd "2" i += N i N j = int(j) + N j int(j) + N int(j) int j N d1 = 0 d1 0 while i < j:
                if i & 1:
                    d1 |= T[i]
                    i += 1
                if j & 1:
                    j -= 1
                    d1 |= T[j]

                i >>= 1; j >>=1

             i < j i j if i & 1:
                    d1 |= T[i]
                    i += 1
                 i & 1 i 1 d1 |= T[i] d1 T[i] T i i += 1 i 1 if j & 1:
                    j -= 1
                    d1 |= T[j]

                 j & 1 j 1 j -= 1 j 1 d1 |= T[j] d1 T[j] T j i >>= 1 i 1 j >>=1 j 1 ans.append(bin(d1).count('1')) ans.append ans append bin(d1).count('1') (d1).count (d1) bin d1 count '1' print(*ans, sep="\n") print *ans ans sep="\n" sep "\n" if __name__ == "__main__":
    resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    N = int(input())
    S = list(input())
    Q = int(input())

    c0 = ord('a')
    smap = [1<<(i-c0) for i in range(c0, ord('z')+1)]

    T = [0]*N + [smap[ord(S[i])-c0] for i in range(N)]

    for i in range(N-1, 0, -1):
        i2 = i << 1
        T[i] = T[i2] | T[i2|1]

    ans = []
    #print(T)
    for cmd, i, j in zip(*[iter(sys.stdin.read().split())]*3):
        i = int(i) - 1
        if cmd == "1":
            if S[i] == j:
                continue

            S[i] = j
            i0 = N + i
            T[i0] = smap[ord(j)-c0]
            while i0 > 1:
                i0 = i0 >> 1
                T[i0] = T[i0+i0] | T[i0-~i0]
        elif cmd == "2":
            i += N
            j = int(j) + N

            d1 = 0
            while i < j:
                if i & 1:
                    d1 |= T[i]
                    i += 1
                if j & 1:
                    j -= 1
                    d1 |= T[j]

                i >>= 1; j >>=1

            ans.append(bin(d1).count('1'))

    print(*ans, sep="\n") def resolve():
    N = int(input())
    S = list(input())
    Q = int(input())

    c0 = ord('a')
    smap = [1<<(i-c0) for i in range(c0, ord('z')+1)]

    T = [0]*N + [smap[ord(S[i])-c0] for i in range(N)]

    for i in range(N-1, 0, -1):
        i2 = i << 1
        T[i] = T[i2] | T[i2|1]

    ans = []
    #print(T)
    for cmd, i, j in zip(*[iter(sys.stdin.read().split())]*3):
        i = int(i) - 1
        if cmd == "1":
            if S[i] == j:
                continue

            S[i] = j
            i0 = N + i
            T[i0] = smap[ord(j)-c0]
            while i0 > 1:
                i0 = i0 >> 1
                T[i0] = T[i0+i0] | T[i0-~i0]
        elif cmd == "2":
            i += N
            j = int(j) + N

            d1 = 0
            while i < j:
                if i & 1:
                    d1 |= T[i]
                    i += 1
                if j & 1:
                    j -= 1
                    d1 |= T[j]

                i >>= 1; j >>=1

            ans.append(bin(d1).count('1'))

    print(*ans, sep="\n") resolve input = sys.stdin.readline sys.stdin.readline input
#!python3

import sys

input = sys.stdin.readline

def resolve():
    N = int(input())
    S = list(input())
    Q = int(input())

    c0 = ord('a')
    smap = [1<<(i-c0) for i in range(c0, ord('z')+1)]

    T = [0]*N + [smap[ord(S[i])-c0] for i in range(N)]

    for i in range(N-1, 0, -1):
        i2 = i << 1
        T[i] = T[i2] | T[i2|1]

    ans = []
    #print(T)
    for cmd, i, j in zip(*[iter(sys.stdin.read().split())]*3):
        i = int(i) - 1
        if cmd == "1":
            if S[i] == j:
                continue

            S[i] = j
            i0 = N + i
            T[i0] = smap[ord(j)-c0]
            while i0 > 1:
                i0 = i0 >> 1
                T[i0] = T[i0+i0] | T[i0-~i0]
        elif cmd == "2":
            i += N
            j = int(j) + N

            d1 = 0
            while i < j:
                if i & 1:
                    d1 |= T[i]
                    i += 1
                if j & 1:
                    j -= 1
                    d1 |= T[j]

                i >>= 1; j >>=1

            ans.append(bin(d1).count('1'))

    print(*ans, sep="\n")

if __name__ == "__main__":
    resolve()
