from bisect import insort_left, bisect_left
n = int(input())
s = list(input())
Q = int(input())
query = [input() for _ in range(Q)]
dic = {chr(i+ord('a')):[] for i in range(26)}
for ind, c in enumerate(s):
    dic[c].append(ind)

for q in query:
    t, a, b = q.split()
    a = int(a)-1
    if t=='1':
        if s[a]==b:
            continue
        ind = bisect_left(dic[s[a]], a)
        dic[s[a]].pop(ind)
        insort_left(dic[b], a)
        s[a] = b
    else:
        b = int(b)-1
        tmp = 0
        for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                tmp += 1
        print(tmp) from bisect import insort_left, bisect_left 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 input() for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) input() input query = [input() for _ in range(Q)] query [input() for _ in range(Q)] chr(i+ord('a')):[] for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) chr(i+ord('a')) chr i+ord('a') i ord('a') ord 'a' [] dic = {chr(i+ord('a')):[] for i in range(26)} dic {chr(i+ord('a')):[] for i in range(26)} for ind, c in enumerate(s):
    dic[c].append(ind) ind c enumerate(s) enumerate s dic[c].append(ind) [c].append [c] dic c append ind for q in query:
    t, a, b = q.split()
    a = int(a)-1
    if t=='1':
        if s[a]==b:
            continue
        ind = bisect_left(dic[s[a]], a)
        dic[s[a]].pop(ind)
        insort_left(dic[b], a)
        s[a] = b
    else:
        b = int(b)-1
        tmp = 0
        for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                tmp += 1
        print(tmp) q query t, a, b = q.split() t q.split() q.split q split a b a = int(a)-1 a int(a)-1 int(a) int a 1 if t=='1':
        if s[a]==b:
            continue
        ind = bisect_left(dic[s[a]], a)
        dic[s[a]].pop(ind)
        insort_left(dic[b], a)
        s[a] = b
    else:
        b = int(b)-1
        tmp = 0
        for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                tmp += 1
        print(tmp) t=='1' t '1' if s[a]==b:
            continue
         s[a]==b s[a] s a b continue ind = bisect_left(dic[s[a]], a) ind bisect_left(dic[s[a]], a) bisect_left dic[s[a]] dic s[a] s a a dic[s[a]].pop(ind) [s[a]].pop [s[a]] dic s[a] s a pop ind insort_left(dic[b], a) insort_left dic[b] dic b a s[a] = b s[a] s a b b = int(b)-1 b int(b)-1 int(b) int b 1 tmp = 0 tmp 0 for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                tmp += 1
         li dic.values() dic.values dic values if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                tmp += 1
         li and a<=li[-1] and li[bisect_left(li, a)] <= b li and a<=li[-1] li a<=li[-1] a li[-1] li -1 li[bisect_left(li, a)] <= b li[bisect_left(li, a)] li bisect_left(li, a) bisect_left li a b tmp += 1 tmp 1 print(tmp) print tmp n = int(input()) int(input()) n tmp += 1 1 tmp b = q.split() q.split() b query = [input() for _ in range(Q)] [input() for _ in range(Q)] query s = list(input()) list(input()) s dic = {chr(i+ord('a')):[] for i in range(26)} {chr(i+ord('a')):[] for i in range(26)} dic ind = bisect_left(dic[s[a]], a) bisect_left(dic[s[a]], a) ind b = int(b)-1 int(b)-1 b a, b = q.split() q.split() a tmp = 0 0 tmp a = int(a)-1 int(a)-1 a t, a, b = q.split() q.split() t Q = int(input()) int(input()) Q
from bisect import insort_left, bisect_left
n = int(input())
s = list(input())
Q = int(input())
query = [input() for _ in range(Q)]
dic = {chr(i+ord('a')):[] for i in range(26)}
for ind, c in enumerate(s):
    dic[c].append(ind)

for q in query:
    t, a, b = q.split()
    a = int(a)-1
    if t=='1':
        if s[a]==b:
            continue
        ind = bisect_left(dic[s[a]], a)
        dic[s[a]].pop(ind)
        insort_left(dic[b], a)
        s[a] = b
    else:
        b = int(b)-1
        tmp = 0
        for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                tmp += 1
        print(tmp)
