import bisect
n=int(input())
s=list(input())
a={chr(i):[] for i in range(97,123)}
for i,c in enumerate(s):
    bisect.insort(a[c],i+1)
for i in range(int(input())):
    p,q,r=list(map(str,input().split()))
    if p=="1":
        q=int(q)
        b=s[q-1]
        if b!=r:
            a[b].pop(bisect.bisect_left(a[b],q))
            bisect.insort(a[r],q)
            s[q-1]=r
    else:
        d=0
        for l in a.values():
            g=bisect.bisect_left(l,int(q))
            if g<len(l) and l[g]<=int(r):
                d+=1
        print(d) 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 [] a={chr(i):[] for i in range(97,123)} a {chr(i):[] for i in range(97,123)} for i,c in enumerate(s):
    bisect.insort(a[c],i+1) i c enumerate(s) enumerate s bisect.insort(a[c],i+1) bisect.insort bisect insort a[c] a c i+1 i 1 for i in range(int(input())):
    p,q,r=list(map(str,input().split()))
    if p=="1":
        q=int(q)
        b=s[q-1]
        if b!=r:
            a[b].pop(bisect.bisect_left(a[b],q))
            bisect.insort(a[r],q)
            s[q-1]=r
    else:
        d=0
        for l in a.values():
            g=bisect.bisect_left(l,int(q))
            if g<len(l) and l[g]<=int(r):
                d+=1
        print(d) i range(int(input())) range int(input()) int input() input p,q,r=list(map(str,input().split())) p list(map(str,input().split())) list map(str,input().split()) map str input().split() ().split () input split q r if p=="1":
        q=int(q)
        b=s[q-1]
        if b!=r:
            a[b].pop(bisect.bisect_left(a[b],q))
            bisect.insort(a[r],q)
            s[q-1]=r
    else:
        d=0
        for l in a.values():
            g=bisect.bisect_left(l,int(q))
            if g<len(l) and l[g]<=int(r):
                d+=1
        print(d) 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:
            a[b].pop(bisect.bisect_left(a[b],q))
            bisect.insort(a[r],q)
            s[q-1]=r
     b!=r b r a[b].pop(bisect.bisect_left(a[b],q)) [b].pop [b] a b pop bisect.bisect_left(a[b],q) bisect.bisect_left bisect bisect_left a[b] a b q bisect.insort(a[r],q) bisect.insort bisect insort a[r] a r q s[q-1]=r s[q-1] s q-1 q 1 r d=0 d 0 for l in a.values():
            g=bisect.bisect_left(l,int(q))
            if g<len(l) and l[g]<=int(r):
                d+=1
         l a.values() a.values a values g=bisect.bisect_left(l,int(q)) g bisect.bisect_left(l,int(q)) bisect.bisect_left bisect bisect_left l int(q) int q if g<len(l) and l[g]<=int(r):
                d+=1
         g<len(l) and l[g]<=int(r) g<len(l) g len(l) len l l[g]<=int(r) l[g] l g int(r) int r d+=1 d 1 print(d) print d q,r=list(map(str,input().split())) list(map(str,input().split())) q g=bisect.bisect_left(l,int(q)) bisect.bisect_left(l,int(q)) g p,q,r=list(map(str,input().split())) list(map(str,input().split())) p s=list(input()) list(input()) s q=int(q) int(q) q r=list(map(str,input().split())) list(map(str,input().split())) r b=s[q-1] s[q-1] b n=int(input()) int(input()) n d=0 0 d d+=1 1 d a={chr(i):[] for i in range(97,123)} {chr(i):[] for i in range(97,123)} a
import bisect
n=int(input())
s=list(input())
a={chr(i):[] for i in range(97,123)}
for i,c in enumerate(s):
    bisect.insort(a[c],i+1)
for i in range(int(input())):
    p,q,r=list(map(str,input().split()))
    if p=="1":
        q=int(q)
        b=s[q-1]
        if b!=r:
            a[b].pop(bisect.bisect_left(a[b],q))
            bisect.insort(a[r],q)
            s[q-1]=r
    else:
        d=0
        for l in a.values():
            g=bisect.bisect_left(l,int(q))
            if g<len(l) and l[g]<=int(r):
                d+=1
        print(d)