# AtCoder Beginner Contest 157
# E - Simple String Queries
# https://atcoder.jp/contests/abc157/tasks/abc157_e
from bisect import bisect_left, insort_left
import sys
input = sys.stdin.readline
OFS = ord('a')
_ = input()
S = list(input()[:-1])

D = [[] for _ in [0]*26]
for i, s in enumerate(S):
    D[ord(s)-OFS].append(i)

for _ in [0]*int(input()):
    Q = input()[:-1].split()
    if Q[0] == '1':
        i, c = int(Q[1])-1, Q[2]

        if S[i] != c:
            s = ord(S[i])-OFS
            D[s].pop(bisect_left(D[s], i))
            insort_left(D[ord(c)-OFS], i)
            S[i] = c

    else:
        l, r = int(Q[1])-1, int(Q[2])-1

        cnt = 0
        for L in D:
            i = bisect_left(L, l)
            if i < len(L) and L[i] <= r:
                cnt += 1

        print(cnt) from bisect import bisect_left, insort_left import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline OFS = ord('a') OFS ord('a') ord 'a' _ = input() _ input() input S = list(input()[:-1]) S list(input()[:-1]) list input()[:-1] () input :-1 -1 [] for _ in [0]*26 for _ in [0]*26 _ [0]*26 [0] 0 26 for _ in [0]*26 [] D = [[] for _ in [0]*26] D [[] for _ in [0]*26] for i, s in enumerate(S):
    D[ord(s)-OFS].append(i) i s enumerate(S) enumerate S D[ord(s)-OFS].append(i) [ord(s)-OFS].append [ord(s)-OFS] D ord(s)-OFS ord(s) ord s OFS append i for _ in [0]*int(input()):
    Q = input()[:-1].split()
    if Q[0] == '1':
        i, c = int(Q[1])-1, Q[2]

        if S[i] != c:
            s = ord(S[i])-OFS
            D[s].pop(bisect_left(D[s], i))
            insort_left(D[ord(c)-OFS], i)
            S[i] = c

    else:
        l, r = int(Q[1])-1, int(Q[2])-1

        cnt = 0
        for L in D:
            i = bisect_left(L, l)
            if i < len(L) and L[i] <= r:
                cnt += 1

        print(cnt) _ [0]*int(input()) [0] 0 int(input()) int input() input Q = input()[:-1].split() Q input()[:-1].split() [:-1].split [:-1] () input :-1 -1 split if Q[0] == '1':
        i, c = int(Q[1])-1, Q[2]

        if S[i] != c:
            s = ord(S[i])-OFS
            D[s].pop(bisect_left(D[s], i))
            insort_left(D[ord(c)-OFS], i)
            S[i] = c

    else:
        l, r = int(Q[1])-1, int(Q[2])-1

        cnt = 0
        for L in D:
            i = bisect_left(L, l)
            if i < len(L) and L[i] <= r:
                cnt += 1

        print(cnt) Q[0] == '1' Q[0] Q 0 '1' i, c = int(Q[1])-1, Q[2] i int(Q[1])-1 int(Q[1]) int Q[1] Q 1 1 c Q[2] Q 2 if S[i] != c:
            s = ord(S[i])-OFS
            D[s].pop(bisect_left(D[s], i))
            insort_left(D[ord(c)-OFS], i)
            S[i] = c

     S[i] != c S[i] S i c s = ord(S[i])-OFS s ord(S[i])-OFS ord(S[i]) ord S[i] S i OFS D[s].pop(bisect_left(D[s], i)) [s].pop [s] D s pop bisect_left(D[s], i) bisect_left D[s] D s i insort_left(D[ord(c)-OFS], i) insort_left D[ord(c)-OFS] D ord(c)-OFS ord(c) ord c OFS i S[i] = c S[i] S i c l, r = int(Q[1])-1, int(Q[2])-1 l int(Q[1])-1 int(Q[1]) int Q[1] Q 1 1 r int(Q[2])-1 int(Q[2]) int Q[2] Q 2 1 cnt = 0 cnt 0 for L in D:
            i = bisect_left(L, l)
            if i < len(L) and L[i] <= r:
                cnt += 1

         L D i = bisect_left(L, l) i bisect_left(L, l) bisect_left L l if i < len(L) and L[i] <= r:
                cnt += 1

         i < len(L) and L[i] <= r i < len(L) i len(L) len L L[i] <= r L[i] L i r cnt += 1 cnt 1 print(cnt) print cnt r = int(Q[1])-1, int(Q[2])-1 int(Q[2])-1 r OFS = ord('a') ord('a') OFS i = bisect_left(L, l) bisect_left(L, l) i S = list(input()[:-1]) list(input()[:-1]) S Q = input()[:-1].split() input()[:-1].split() Q i, c = int(Q[1])-1, Q[2] int(Q[1])-1 i l, r = int(Q[1])-1, int(Q[2])-1 int(Q[1])-1 l D = [[] for _ in [0]*26] [[] for _ in [0]*26] D input = sys.stdin.readline sys.stdin.readline input cnt += 1 1 cnt c = int(Q[1])-1, Q[2] Q[2] c s = ord(S[i])-OFS ord(S[i])-OFS s cnt = 0 0 cnt _ = input() input() _
# AtCoder Beginner Contest 157
# E - Simple String Queries
# https://atcoder.jp/contests/abc157/tasks/abc157_e
from bisect import bisect_left, insort_left
import sys
input = sys.stdin.readline
OFS = ord('a')
_ = input()
S = list(input()[:-1])

D = [[] for _ in [0]*26]
for i, s in enumerate(S):
    D[ord(s)-OFS].append(i)

for _ in [0]*int(input()):
    Q = input()[:-1].split()
    if Q[0] == '1':
        i, c = int(Q[1])-1, Q[2]

        if S[i] != c:
            s = ord(S[i])-OFS
            D[s].pop(bisect_left(D[s], i))
            insort_left(D[ord(c)-OFS], i)
            S[i] = c

    else:
        l, r = int(Q[1])-1, int(Q[2])-1

        cnt = 0
        for L in D:
            i = bisect_left(L, l)
            if i < len(L) and L[i] <= r:
                cnt += 1

        print(cnt)
