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 i, s in enumerate(S):
    dic[s].append(i)
for q in Query:
    t,a,b = q.split()
    a = int(a)-1
    if(t == "1"):
        if(S[a]==b):
            continue
        tmp_index = bisect_left(dic[S[a]],a)
        dic[S[a]].pop(tmp_index)
        insort_left(dic[b],a)
        S[a] = b
    elif(t == "2"):
        b = int(b)-1
        cnt = 0
        for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                cnt += 1
        print(cnt) 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 i, s in enumerate(S):
    dic[s].append(i) i s enumerate(S) enumerate S dic[s].append(i) [s].append [s] dic s append i for q in Query:
    t,a,b = q.split()
    a = int(a)-1
    if(t == "1"):
        if(S[a]==b):
            continue
        tmp_index = bisect_left(dic[S[a]],a)
        dic[S[a]].pop(tmp_index)
        insort_left(dic[b],a)
        S[a] = b
    elif(t == "2"):
        b = int(b)-1
        cnt = 0
        for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                cnt += 1
        print(cnt) 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
        tmp_index = bisect_left(dic[S[a]],a)
        dic[S[a]].pop(tmp_index)
        insort_left(dic[b],a)
        S[a] = b
    elif(t == "2"):
        b = int(b)-1
        cnt = 0
        for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                cnt += 1
        print(cnt) t == "1" t "1" if(S[a]==b):
            continue
         S[a]==b S[a] S a b continue tmp_index = bisect_left(dic[S[a]],a) tmp_index bisect_left(dic[S[a]],a) bisect_left dic[S[a]] dic S[a] S a a dic[S[a]].pop(tmp_index) [S[a]].pop [S[a]] dic S[a] S a pop tmp_index insort_left(dic[b],a) insort_left dic[b] dic b a S[a] = b S[a] S a b elif(t == "2"):
        b = int(b)-1
        cnt = 0
        for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                cnt += 1
        print(cnt) t == "2" t "2" b = int(b)-1 b int(b)-1 int(b) int b 1 cnt = 0 cnt 0 for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                cnt += 1
         li dic.values() dic.values dic values if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                cnt += 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 cnt += 1 cnt 1 print(cnt) print cnt tmp_index = bisect_left(dic[S[a]],a) bisect_left(dic[S[a]],a) tmp_index Q = int(input()) int(input()) Q N = int(input()) int(input()) N a = int(a)-1 int(a)-1 a S = list(input()) list(input()) S b = int(b)-1 int(b)-1 b a,b = q.split() q.split() a Query = [input() for _ in range(Q)] [input() for _ in range(Q)] Query t,a,b = q.split() q.split() t cnt += 1 1 cnt cnt = 0 0 cnt b = q.split() q.split() b dic = {chr(i+ord("a")):[] for i in range(26)} {chr(i+ord("a")):[] for i in range(26)} dic
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 i, s in enumerate(S):
    dic[s].append(i)
for q in Query:
    t,a,b = q.split()
    a = int(a)-1
    if(t == "1"):
        if(S[a]==b):
            continue
        tmp_index = bisect_left(dic[S[a]],a)
        dic[S[a]].pop(tmp_index)
        insort_left(dic[b],a)
        S[a] = b
    elif(t == "2"):
        b = int(b)-1
        cnt = 0
        for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                cnt += 1
        print(cnt)