class segtree:
    def __init__(self,N):
        self.n=(1<<len(bin(N-1)[2:]))
        self.x=[0 for _ in range(2*self.n)]
    def build(self,seq):
        for i, j in enumerate(seq, start=self.n):
            self.x[i]=1<<j
        for i in range(self.n-1, 0, -1):
            self.x[i]=self.x[i*2]|self.x[i*2+1]
    def update(self, i, c):
        j=i+self.n
        self.x[j]=1<<c
        while j>1:
            j//=2
            self.x[j]=self.x[j*2]|self.x[j*2+1]
    def get(self,l,r):
        ans=0
        l+=self.n
        r+=self.n
        while l<r:
            if l%2==1:
                ans|=self.x[l]
                l+=1
            if r%2==0:
                ans|=self.x[r]
                r-=1
            l//=2
            r//=2
        if l==r:
            ans|=self.x[l]
        cnt=sum(list(map(int, list(bin(ans)[2:]))))
        print(cnt)
        
n=int(input())
s=list(input())
s=[ord(i)-97 for i in s]
seg=segtree(n)
seg.build(s)
#print(seg.x)
for _ in range(int(input())):
    que=list(input().split())
    if que[0]=='1':
        seg.update(int(que[1])-1, ord(que[2])-97)
    elif que[0]=='2':
        seg.get(int(que[1])-1,int(que[2])-1) class segtree:
    def __init__(self,N):
        self.n=(1<<len(bin(N-1)[2:]))
        self.x=[0 for _ in range(2*self.n)]
    def build(self,seq):
        for i, j in enumerate(seq, start=self.n):
            self.x[i]=1<<j
        for i in range(self.n-1, 0, -1):
            self.x[i]=self.x[i*2]|self.x[i*2+1]
    def update(self, i, c):
        j=i+self.n
        self.x[j]=1<<c
        while j>1:
            j//=2
            self.x[j]=self.x[j*2]|self.x[j*2+1]
    def get(self,l,r):
        ans=0
        l+=self.n
        r+=self.n
        while l<r:
            if l%2==1:
                ans|=self.x[l]
                l+=1
            if r%2==0:
                ans|=self.x[r]
                r-=1
            l//=2
            r//=2
        if l==r:
            ans|=self.x[l]
        cnt=sum(list(map(int, list(bin(ans)[2:]))))
        print(cnt)
         segtree def __init__(self,N):
        self.n=(1<<len(bin(N-1)[2:]))
        self.x=[0 for _ in range(2*self.n)]
     __init__ self.n=(1<<len(bin(N-1)[2:])) self.n self n 1<<len(bin(N-1)[2:]) 1 len(bin(N-1)[2:]) len bin(N-1)[2:] (N-1) bin N-1 N 1 2: 2 0 for _ in range(2*self.n) for _ in range(2*self.n) _ range(2*self.n) range 2*self.n 2 self.n self n for _ in range(2*self.n) 0 self.x=[0 for _ in range(2*self.n)] self.x self x [0 for _ in range(2*self.n)] self self N N def build(self,seq):
        for i, j in enumerate(seq, start=self.n):
            self.x[i]=1<<j
        for i in range(self.n-1, 0, -1):
            self.x[i]=self.x[i*2]|self.x[i*2+1]
     build for i, j in enumerate(seq, start=self.n):
            self.x[i]=1<<j
         i j enumerate(seq, start=self.n) enumerate seq start=self.n start self.n self n self.x[i]=1<<j self.x[i] self.x self x i 1<<j 1 j for i in range(self.n-1, 0, -1):
            self.x[i]=self.x[i*2]|self.x[i*2+1]
     i range(self.n-1, 0, -1) range self.n-1 self.n self n 1 0 -1 self.x[i]=self.x[i*2]|self.x[i*2+1] self.x[i] self.x self x i self.x[i*2]|self.x[i*2+1] self.x[i*2] self.x self x i*2 i 2 self.x[i*2+1] self.x self x i*2+1 i*2 i 2 1 self self seq seq def update(self, i, c):
        j=i+self.n
        self.x[j]=1<<c
        while j>1:
            j//=2
            self.x[j]=self.x[j*2]|self.x[j*2+1]
     update j=i+self.n j i+self.n i self.n self n self.x[j]=1<<c self.x[j] self.x self x j 1<<c 1 c while j>1:
            j//=2
            self.x[j]=self.x[j*2]|self.x[j*2+1]
     j>1 j 1 j//=2 j 2 self.x[j]=self.x[j*2]|self.x[j*2+1] self.x[j] self.x self x j self.x[j*2]|self.x[j*2+1] self.x[j*2] self.x self x j*2 j 2 self.x[j*2+1] self.x self x j*2+1 j*2 j 2 1 self self i i c c def get(self,l,r):
        ans=0
        l+=self.n
        r+=self.n
        while l<r:
            if l%2==1:
                ans|=self.x[l]
                l+=1
            if r%2==0:
                ans|=self.x[r]
                r-=1
            l//=2
            r//=2
        if l==r:
            ans|=self.x[l]
        cnt=sum(list(map(int, list(bin(ans)[2:]))))
        print(cnt)
         get ans=0 ans 0 l+=self.n l self.n self n r+=self.n r self.n self n while l<r:
            if l%2==1:
                ans|=self.x[l]
                l+=1
            if r%2==0:
                ans|=self.x[r]
                r-=1
            l//=2
            r//=2
         l<r l r if l%2==1:
                ans|=self.x[l]
                l+=1
             l%2==1 l%2 l 2 1 ans|=self.x[l] ans self.x[l] self.x self x l l+=1 l 1 if r%2==0:
                ans|=self.x[r]
                r-=1
             r%2==0 r%2 r 2 0 ans|=self.x[r] ans self.x[r] self.x self x r r-=1 r 1 l//=2 l 2 r//=2 r 2 if l==r:
            ans|=self.x[l]
         l==r l r ans|=self.x[l] ans self.x[l] self.x self x l cnt=sum(list(map(int, list(bin(ans)[2:])))) cnt sum(list(map(int, list(bin(ans)[2:])))) sum list(map(int, list(bin(ans)[2:]))) list map(int, list(bin(ans)[2:])) map int list(bin(ans)[2:]) list bin(ans)[2:] (ans) bin ans 2: 2 print(cnt) print cnt self self l l r r n=int(input()) n int(input()) int input() input s=list(input()) s list(input()) list input() input ord(i)-97 for i in s for i in s i s for i in s ord(i)-97 ord(i) ord i 97 s=[ord(i)-97 for i in s] s [ord(i)-97 for i in s] seg=segtree(n) seg segtree(n) segtree n seg.build(s) seg.build seg build s for _ in range(int(input())):
    que=list(input().split())
    if que[0]=='1':
        seg.update(int(que[1])-1, ord(que[2])-97)
    elif que[0]=='2':
        seg.get(int(que[1])-1,int(que[2])-1) _ range(int(input())) range int(input()) int input() input que=list(input().split()) que list(input().split()) list input().split() ().split () input split if que[0]=='1':
        seg.update(int(que[1])-1, ord(que[2])-97)
    elif que[0]=='2':
        seg.get(int(que[1])-1,int(que[2])-1) que[0]=='1' que[0] que 0 '1' seg.update(int(que[1])-1, ord(que[2])-97) seg.update seg update int(que[1])-1 int(que[1]) int que[1] que 1 1 ord(que[2])-97 ord(que[2]) ord que[2] que 2 97 elif que[0]=='2':
        seg.get(int(que[1])-1,int(que[2])-1) que[0]=='2' que[0] que 0 '2' seg.get(int(que[1])-1,int(que[2])-1) seg.get seg get int(que[1])-1 int(que[1]) int que[1] que 1 1 int(que[2])-1 int(que[2]) int que[2] que 2 1 s=[ord(i)-97 for i in s] [ord(i)-97 for i in s] s s=list(input()) list(input()) s seg=segtree(n) segtree(n) seg n=int(input()) int(input()) n class segtree:
    def __init__(self,N):
        self.n=(1<<len(bin(N-1)[2:]))
        self.x=[0 for _ in range(2*self.n)]
    def build(self,seq):
        for i, j in enumerate(seq, start=self.n):
            self.x[i]=1<<j
        for i in range(self.n-1, 0, -1):
            self.x[i]=self.x[i*2]|self.x[i*2+1]
    def update(self, i, c):
        j=i+self.n
        self.x[j]=1<<c
        while j>1:
            j//=2
            self.x[j]=self.x[j*2]|self.x[j*2+1]
    def get(self,l,r):
        ans=0
        l+=self.n
        r+=self.n
        while l<r:
            if l%2==1:
                ans|=self.x[l]
                l+=1
            if r%2==0:
                ans|=self.x[r]
                r-=1
            l//=2
            r//=2
        if l==r:
            ans|=self.x[l]
        cnt=sum(list(map(int, list(bin(ans)[2:]))))
        print(cnt)
         class segtree:
    def __init__(self,N):
        self.n=(1<<len(bin(N-1)[2:]))
        self.x=[0 for _ in range(2*self.n)]
    def build(self,seq):
        for i, j in enumerate(seq, start=self.n):
            self.x[i]=1<<j
        for i in range(self.n-1, 0, -1):
            self.x[i]=self.x[i*2]|self.x[i*2+1]
    def update(self, i, c):
        j=i+self.n
        self.x[j]=1<<c
        while j>1:
            j//=2
            self.x[j]=self.x[j*2]|self.x[j*2+1]
    def get(self,l,r):
        ans=0
        l+=self.n
        r+=self.n
        while l<r:
            if l%2==1:
                ans|=self.x[l]
                l+=1
            if r%2==0:
                ans|=self.x[r]
                r-=1
            l//=2
            r//=2
        if l==r:
            ans|=self.x[l]
        cnt=sum(list(map(int, list(bin(ans)[2:]))))
        print(cnt)
         segtree que=list(input().split()) list(input().split()) que
class segtree:
    def __init__(self,N):
        self.n=(1<<len(bin(N-1)[2:]))
        self.x=[0 for _ in range(2*self.n)]
    def build(self,seq):
        for i, j in enumerate(seq, start=self.n):
            self.x[i]=1<<j
        for i in range(self.n-1, 0, -1):
            self.x[i]=self.x[i*2]|self.x[i*2+1]
    def update(self, i, c):
        j=i+self.n
        self.x[j]=1<<c
        while j>1:
            j//=2
            self.x[j]=self.x[j*2]|self.x[j*2+1]
    def get(self,l,r):
        ans=0
        l+=self.n
        r+=self.n
        while l<r:
            if l%2==1:
                ans|=self.x[l]
                l+=1
            if r%2==0:
                ans|=self.x[r]
                r-=1
            l//=2
            r//=2
        if l==r:
            ans|=self.x[l]
        cnt=sum(list(map(int, list(bin(ans)[2:]))))
        print(cnt)
        
n=int(input())
s=list(input())
s=[ord(i)-97 for i in s]
seg=segtree(n)
seg.build(s)
#print(seg.x)
for _ in range(int(input())):
    que=list(input().split())
    if que[0]=='1':
        seg.update(int(que[1])-1, ord(que[2])-97)
    elif que[0]=='2':
        seg.get(int(que[1])-1,int(que[2])-1)