import bisect

n=int(input())
s=list(input())

#アルファベットの各文字に対してからのリストを持つ辞書
alpha={chr(i):[] for i in range(97,123)}

#alpha[c]で各文字ごとに出現場所をソートして保管
for i,c in enumerate(s):
    bisect.insort(alpha[c],i+1)

for i in range(int(input())):
    p,q,r=input().split()
    if p=='1':
        q=int(q)
        b=s[q-1]
        if b!=r:
            alpha[b].pop(bisect.bisect_left(alpha[b],q))
            bisect.insort(alpha[r],q)
            s[q-1]=r
    else:
        count=0
        for l in alpha.values():
            pos=bisect.bisect_left(l,int(q))
            if pos<len(l) and l[pos]<=int(r):
                count+=1
        print(count) import bisect bisect n=int(input()) n int(input()) int input() input s=list(input()) s list(input()) list input() input chr(i):[] for i in range(97,123) for i in range(97,123) i range(97,123) range 97 123 for i in range(97,123) chr(i) chr i [] alpha={chr(i):[] for i in range(97,123)} alpha {chr(i):[] for i in range(97,123)} for i,c in enumerate(s):
    bisect.insort(alpha[c],i+1) i c enumerate(s) enumerate s bisect.insort(alpha[c],i+1) bisect.insort bisect insort alpha[c] alpha c i+1 i 1 for i in range(int(input())):
    p,q,r=input().split()
    if p=='1':
        q=int(q)
        b=s[q-1]
        if b!=r:
            alpha[b].pop(bisect.bisect_left(alpha[b],q))
            bisect.insort(alpha[r],q)
            s[q-1]=r
    else:
        count=0
        for l in alpha.values():
            pos=bisect.bisect_left(l,int(q))
            if pos<len(l) and l[pos]<=int(r):
                count+=1
        print(count) i range(int(input())) range int(input()) int input() input p,q,r=input().split() p input().split() ().split () input split q r if p=='1':
        q=int(q)
        b=s[q-1]
        if b!=r:
            alpha[b].pop(bisect.bisect_left(alpha[b],q))
            bisect.insort(alpha[r],q)
            s[q-1]=r
    else:
        count=0
        for l in alpha.values():
            pos=bisect.bisect_left(l,int(q))
            if pos<len(l) and l[pos]<=int(r):
                count+=1
        print(count) p=='1' p '1' q=int(q) q int(q) int q b=s[q-1] b s[q-1] s q-1 q 1 if b!=r:
            alpha[b].pop(bisect.bisect_left(alpha[b],q))
            bisect.insort(alpha[r],q)
            s[q-1]=r
     b!=r b r alpha[b].pop(bisect.bisect_left(alpha[b],q)) [b].pop [b] alpha b pop bisect.bisect_left(alpha[b],q) bisect.bisect_left bisect bisect_left alpha[b] alpha b q bisect.insort(alpha[r],q) bisect.insort bisect insort alpha[r] alpha r q s[q-1]=r s[q-1] s q-1 q 1 r count=0 count 0 for l in alpha.values():
            pos=bisect.bisect_left(l,int(q))
            if pos<len(l) and l[pos]<=int(r):
                count+=1
         l alpha.values() alpha.values alpha values pos=bisect.bisect_left(l,int(q)) pos bisect.bisect_left(l,int(q)) bisect.bisect_left bisect bisect_left l int(q) int q if pos<len(l) and l[pos]<=int(r):
                count+=1
         pos<len(l) and l[pos]<=int(r) pos<len(l) pos len(l) len l l[pos]<=int(r) l[pos] l pos int(r) int r count+=1 count 1 print(count) print count alpha={chr(i):[] for i in range(97,123)} {chr(i):[] for i in range(97,123)} alpha q,r=input().split() input().split() q n=int(input()) int(input()) n pos=bisect.bisect_left(l,int(q)) bisect.bisect_left(l,int(q)) pos b=s[q-1] s[q-1] b count+=1 1 count r=input().split() input().split() r p,q,r=input().split() input().split() p s=list(input()) list(input()) s q=int(q) int(q) q count=0 0 count
import bisect

n=int(input())
s=list(input())

#アルファベットの各文字に対してからのリストを持つ辞書
alpha={chr(i):[] for i in range(97,123)}

#alpha[c]で各文字ごとに出現場所をソートして保管
for i,c in enumerate(s):
    bisect.insort(alpha[c],i+1)

for i in range(int(input())):
    p,q,r=input().split()
    if p=='1':
        q=int(q)
        b=s[q-1]
        if b!=r:
            alpha[b].pop(bisect.bisect_left(alpha[b],q))
            bisect.insort(alpha[r],q)
            s[q-1]=r
    else:
        count=0
        for l in alpha.values():
            pos=bisect.bisect_left(l,int(q))
            if pos<len(l) and l[pos]<=int(r):
                count+=1
        print(count)
