import bisect
n = int(input().strip())
S = list(input().strip())
L=[[] for _ in range(26)]
for i,s in enumerate(S):
    L[ord(s)-ord("a")].append(i)

q = int(input().strip())
for _ in range(q):
    query=input().strip().split()
    if query[0]=="1":
        i=int(query[1])
        i-=1
        c=query[2]
        if S[i]!=c:
            delInd=bisect.bisect_left(L[ord(S[i])-ord("a")],i)
            del L[ord(S[i])-ord("a")][delInd]
            bisect.insort(L[ord(c)-ord("a")], i)
            S[i]=c
    else:
        l,r=map(int,[query[1],query[2]])
        l-=1; r-=1
        ans=0
        for j in range(26):
            ind=bisect.bisect_left(L[j],l)
            if ind<len(L[j]) and L[j][ind]<=r:
                ans+=1
        print(ans) import bisect bisect n = int(input().strip()) n int(input().strip()) int input().strip() ().strip () input strip S = list(input().strip()) S list(input().strip()) list input().strip() ().strip () input strip [] for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [] L=[[] for _ in range(26)] L [[] for _ in range(26)] for i,s in enumerate(S):
    L[ord(s)-ord("a")].append(i) i s enumerate(S) enumerate S L[ord(s)-ord("a")].append(i) [ord(s)-ord("a")].append [ord(s)-ord("a")] L ord(s)-ord("a") ord(s) ord s ord("a") ord "a" append i q = int(input().strip()) q int(input().strip()) int input().strip() ().strip () input strip for _ in range(q):
    query=input().strip().split()
    if query[0]=="1":
        i=int(query[1])
        i-=1
        c=query[2]
        if S[i]!=c:
            delInd=bisect.bisect_left(L[ord(S[i])-ord("a")],i)
            del L[ord(S[i])-ord("a")][delInd]
            bisect.insort(L[ord(c)-ord("a")], i)
            S[i]=c
    else:
        l,r=map(int,[query[1],query[2]])
        l-=1; r-=1
        ans=0
        for j in range(26):
            ind=bisect.bisect_left(L[j],l)
            if ind<len(L[j]) and L[j][ind]<=r:
                ans+=1
        print(ans) _ range(q) range q query=input().strip().split() query input().strip().split() ().strip().split ().strip() ().strip () input strip split if query[0]=="1":
        i=int(query[1])
        i-=1
        c=query[2]
        if S[i]!=c:
            delInd=bisect.bisect_left(L[ord(S[i])-ord("a")],i)
            del L[ord(S[i])-ord("a")][delInd]
            bisect.insort(L[ord(c)-ord("a")], i)
            S[i]=c
    else:
        l,r=map(int,[query[1],query[2]])
        l-=1; r-=1
        ans=0
        for j in range(26):
            ind=bisect.bisect_left(L[j],l)
            if ind<len(L[j]) and L[j][ind]<=r:
                ans+=1
        print(ans) query[0]=="1" query[0] query 0 "1" i=int(query[1]) i int(query[1]) int query[1] query 1 i-=1 i 1 c=query[2] c query[2] query 2 if S[i]!=c:
            delInd=bisect.bisect_left(L[ord(S[i])-ord("a")],i)
            del L[ord(S[i])-ord("a")][delInd]
            bisect.insort(L[ord(c)-ord("a")], i)
            S[i]=c
     S[i]!=c S[i] S i c delInd=bisect.bisect_left(L[ord(S[i])-ord("a")],i) delInd bisect.bisect_left(L[ord(S[i])-ord("a")],i) bisect.bisect_left bisect bisect_left L[ord(S[i])-ord("a")] L ord(S[i])-ord("a") ord(S[i]) ord S[i] S i ord("a") ord "a" i del L[ord(S[i])-ord("a")][delInd] L[ord(S[i])-ord("a")][delInd] [ord(S[i])-ord("a")] L ord(S[i])-ord("a") ord(S[i]) ord S[i] S i ord("a") ord "a" delInd bisect.insort(L[ord(c)-ord("a")], i) bisect.insort bisect insort L[ord(c)-ord("a")] L ord(c)-ord("a") ord(c) ord c ord("a") ord "a" i S[i]=c S[i] S i c l,r=map(int,[query[1],query[2]]) l map(int,[query[1],query[2]]) map int [query[1],query[2]] query[1] query 1 query[2] query 2 r l-=1 l 1 r-=1 r 1 ans=0 ans 0 for j in range(26):
            ind=bisect.bisect_left(L[j],l)
            if ind<len(L[j]) and L[j][ind]<=r:
                ans+=1
         j range(26) range 26 ind=bisect.bisect_left(L[j],l) ind bisect.bisect_left(L[j],l) bisect.bisect_left bisect bisect_left L[j] L j l if ind<len(L[j]) and L[j][ind]<=r:
                ans+=1
         ind<len(L[j]) and L[j][ind]<=r ind<len(L[j]) ind len(L[j]) len L[j] L j L[j][ind]<=r L[j][ind] [j] L j ind r ans+=1 ans 1 print(ans) print ans L=[[] for _ in range(26)] [[] for _ in range(26)] L S = list(input().strip()) list(input().strip()) S n = int(input().strip()) int(input().strip()) n r=map(int,[query[1],query[2]]) map(int,[query[1],query[2]]) r i=int(query[1]) int(query[1]) i i-=1 1 i query=input().strip().split() input().strip().split() query c=query[2] query[2] c r-=1 1 r l-=1 1 l delInd=bisect.bisect_left(L[ord(S[i])-ord("a")],i) bisect.bisect_left(L[ord(S[i])-ord("a")],i) delInd l,r=map(int,[query[1],query[2]]) map(int,[query[1],query[2]]) l ind=bisect.bisect_left(L[j],l) bisect.bisect_left(L[j],l) ind q = int(input().strip()) int(input().strip()) q ans=0 0 ans ans+=1 1 ans
import bisect
n = int(input().strip())
S = list(input().strip())
L=[[] for _ in range(26)]
for i,s in enumerate(S):
    L[ord(s)-ord("a")].append(i)

q = int(input().strip())
for _ in range(q):
    query=input().strip().split()
    if query[0]=="1":
        i=int(query[1])
        i-=1
        c=query[2]
        if S[i]!=c:
            delInd=bisect.bisect_left(L[ord(S[i])-ord("a")],i)
            del L[ord(S[i])-ord("a")][delInd]
            bisect.insort(L[ord(c)-ord("a")], i)
            S[i]=c
    else:
        l,r=map(int,[query[1],query[2]])
        l-=1; r-=1
        ans=0
        for j in range(26):
            ind=bisect.bisect_left(L[j],l)
            if ind<len(L[j]) and L[j][ind]<=r:
                ans+=1
        print(ans)