n=int(input())
from bisect import bisect_left,bisect_right
s=list(input())
q=int(input())
D={chr(ord("a")+i):[] for i in range(26)}
for i ,j in enumerate(s):
    D[j].append(i)
ans=0
for i in range(q):
    x=list(input().split())
    if x[0]=="1":
        l=int(x[1])
        l-=1
        r=x[-1]
        if r==s[l]:
            continue
        rr=bisect_left(D[r],l)
        D[s[l]].remove(l)
        D[r].insert(rr,l)
        s[l]=r
    else:
        l=int(x[1])
        r=int(x[2])
        l-=1
        r-=1
        ans=0
        for i in range(26):
            W=chr(ord("a")+i)
            ll=bisect_left(D[W],l)
            rr=bisect_right(D[W],r)
            if rr-ll>0:
                ans+=1
        print(ans)
 n=int(input()) n int(input()) int input() input from bisect import bisect_left,bisect_right s=list(input()) s list(input()) list input() input q=int(input()) q int(input()) int input() input chr(ord("a")+i):[] for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) chr(ord("a")+i) chr ord("a")+i ord("a") ord "a" i [] D={chr(ord("a")+i):[] for i in range(26)} D {chr(ord("a")+i):[] for i in range(26)} for i ,j in enumerate(s):
    D[j].append(i) i j enumerate(s) enumerate s D[j].append(i) [j].append [j] D j append i ans=0 ans 0 for i in range(q):
    x=list(input().split())
    if x[0]=="1":
        l=int(x[1])
        l-=1
        r=x[-1]
        if r==s[l]:
            continue
        rr=bisect_left(D[r],l)
        D[s[l]].remove(l)
        D[r].insert(rr,l)
        s[l]=r
    else:
        l=int(x[1])
        r=int(x[2])
        l-=1
        r-=1
        ans=0
        for i in range(26):
            W=chr(ord("a")+i)
            ll=bisect_left(D[W],l)
            rr=bisect_right(D[W],r)
            if rr-ll>0:
                ans+=1
        print(ans) i range(q) range q x=list(input().split()) x list(input().split()) list input().split() ().split () input split if x[0]=="1":
        l=int(x[1])
        l-=1
        r=x[-1]
        if r==s[l]:
            continue
        rr=bisect_left(D[r],l)
        D[s[l]].remove(l)
        D[r].insert(rr,l)
        s[l]=r
    else:
        l=int(x[1])
        r=int(x[2])
        l-=1
        r-=1
        ans=0
        for i in range(26):
            W=chr(ord("a")+i)
            ll=bisect_left(D[W],l)
            rr=bisect_right(D[W],r)
            if rr-ll>0:
                ans+=1
        print(ans) x[0]=="1" x[0] x 0 "1" l=int(x[1]) l int(x[1]) int x[1] x 1 l-=1 l 1 r=x[-1] r x[-1] x -1 if r==s[l]:
            continue
         r==s[l] r s[l] s l continue rr=bisect_left(D[r],l) rr bisect_left(D[r],l) bisect_left D[r] D r l D[s[l]].remove(l) [s[l]].remove [s[l]] D s[l] s l remove l D[r].insert(rr,l) [r].insert [r] D r insert rr l s[l]=r s[l] s l r l=int(x[1]) l int(x[1]) int x[1] x 1 r=int(x[2]) r int(x[2]) int x[2] x 2 l-=1 l 1 r-=1 r 1 ans=0 ans 0 for i in range(26):
            W=chr(ord("a")+i)
            ll=bisect_left(D[W],l)
            rr=bisect_right(D[W],r)
            if rr-ll>0:
                ans+=1
         i range(26) range 26 W=chr(ord("a")+i) W chr(ord("a")+i) chr ord("a")+i ord("a") ord "a" i ll=bisect_left(D[W],l) ll bisect_left(D[W],l) bisect_left D[W] D W l rr=bisect_right(D[W],r) rr bisect_right(D[W],r) bisect_right D[W] D W r if rr-ll>0:
                ans+=1
         rr-ll>0 rr-ll rr ll 0 ans+=1 ans 1 print(ans) print ans rr=bisect_right(D[W],r) bisect_right(D[W],r) rr l=int(x[1]) int(x[1]) l W=chr(ord("a")+i) chr(ord("a")+i) W ans=0 0 ans x=list(input().split()) list(input().split()) x l=int(x[1]) int(x[1]) l n=int(input()) int(input()) n r=x[-1] x[-1] r ans+=1 1 ans D={chr(ord("a")+i):[] for i in range(26)} {chr(ord("a")+i):[] for i in range(26)} D ll=bisect_left(D[W],l) bisect_left(D[W],l) ll r=int(x[2]) int(x[2]) r s=list(input()) list(input()) s ans=0 0 ans l-=1 1 l r-=1 1 r l-=1 1 l rr=bisect_left(D[r],l) bisect_left(D[r],l) rr q=int(input()) int(input()) q
n=int(input())
from bisect import bisect_left,bisect_right
s=list(input())
q=int(input())
D={chr(ord("a")+i):[] for i in range(26)}
for i ,j in enumerate(s):
    D[j].append(i)
ans=0
for i in range(q):
    x=list(input().split())
    if x[0]=="1":
        l=int(x[1])
        l-=1
        r=x[-1]
        if r==s[l]:
            continue
        rr=bisect_left(D[r],l)
        D[s[l]].remove(l)
        D[r].insert(rr,l)
        s[l]=r
    else:
        l=int(x[1])
        r=int(x[2])
        l-=1
        r-=1
        ans=0
        for i in range(26):
            W=chr(ord("a")+i)
            ll=bisect_left(D[W],l)
            rr=bisect_right(D[W],r)
            if rr-ll>0:
                ans+=1
        print(ans)

