def popcount(x):
    return bin(x).count('1')

def initialize(N):
    i=1
    while i<N:
        i*=2
    return [0]*(2*i-1),i

def update(i,x):
    i+=d-1
    bit=ord(x)-97
    SEG[i]=0 | (1<<bit)
    while i>0:
        i=(i-1)//2
        SEG[i]=SEG[i*2+1]|SEG[i*2+2]
        
def find(a,b,k,l,r):
    if r<=a or b<=l:
        return 0
    if a<=l and r<=b:
        return SEG[k]
    else:
        c1=find(a,b,2*k+1,l,(l+r)//2)
        c2=find(a,b,2*k+2,(l+r)//2,r)
        return c1|c2
        
N=int(input())
S=input()
Q=int(input())
SEG,d=initialize(N)
for i in range(N):
    update(i,S[i])
for i in range(Q):
    com,s,t=map(str,input().split())
    if(com=='1'):
        update(int(s)-1,t)
    else:
        print(popcount(find(int(s)-1,int(t),0,0,d))) def popcount(x):
    return bin(x).count('1') popcount return bin(x).count('1') bin(x).count('1') (x).count (x) bin x count '1' x x def initialize(N):
    i=1
    while i<N:
        i*=2
    return [0]*(2*i-1),i initialize i=1 i 1 while i<N:
        i*=2
     i<N i N i*=2 i 2 return [0]*(2*i-1),i return [0]*(2*i-1),i [0]*(2*i-1) [0] 0 2*i-1 2*i 2 i 1 i N N def update(i,x):
    i+=d-1
    bit=ord(x)-97
    SEG[i]=0 | (1<<bit)
    while i>0:
        i=(i-1)//2
        SEG[i]=SEG[i*2+1]|SEG[i*2+2]
         update i+=d-1 i d-1 d 1 bit=ord(x)-97 bit ord(x)-97 ord(x) ord x 97 SEG[i]=0 | (1<<bit) SEG[i] SEG i 0 | (1<<bit) 0 1<<bit 1 bit while i>0:
        i=(i-1)//2
        SEG[i]=SEG[i*2+1]|SEG[i*2+2]
         i>0 i 0 i=(i-1)//2 i (i-1)//2 i-1 i 1 2 SEG[i]=SEG[i*2+1]|SEG[i*2+2] SEG[i] SEG i SEG[i*2+1]|SEG[i*2+2] SEG[i*2+1] SEG i*2+1 i*2 i 2 1 SEG[i*2+2] SEG i*2+2 i*2 i 2 2 i i x x def find(a,b,k,l,r):
    if r<=a or b<=l:
        return 0
    if a<=l and r<=b:
        return SEG[k]
    else:
        c1=find(a,b,2*k+1,l,(l+r)//2)
        c2=find(a,b,2*k+2,(l+r)//2,r)
        return c1|c2
         find if r<=a or b<=l:
        return 0
     r<=a or b<=l r<=a r a b<=l b l return 0 0 if a<=l and r<=b:
        return SEG[k]
    else:
        c1=find(a,b,2*k+1,l,(l+r)//2)
        c2=find(a,b,2*k+2,(l+r)//2,r)
        return c1|c2
         a<=l and r<=b a<=l a l r<=b r b return SEG[k] SEG[k] SEG k c1=find(a,b,2*k+1,l,(l+r)//2) c1 find(a,b,2*k+1,l,(l+r)//2) find a b 2*k+1 2*k 2 k 1 l (l+r)//2 l+r l r 2 c2=find(a,b,2*k+2,(l+r)//2,r) c2 find(a,b,2*k+2,(l+r)//2,r) find a b 2*k+2 2*k 2 k 2 (l+r)//2 l+r l r 2 r return c1|c2 c1|c2 c1 c2 a a b b k k l l r r N=int(input()) N int(input()) int input() input S=input() S input() input Q=int(input()) Q int(input()) int input() input SEG,d=initialize(N) SEG initialize(N) initialize N d for i in range(N):
    update(i,S[i]) i range(N) range N update(i,S[i]) update i S[i] S i for i in range(Q):
    com,s,t=map(str,input().split())
    if(com=='1'):
        update(int(s)-1,t)
    else:
        print(popcount(find(int(s)-1,int(t),0,0,d))) i range(Q) range Q com,s,t=map(str,input().split()) com map(str,input().split()) map str input().split() ().split () input split s t if(com=='1'):
        update(int(s)-1,t)
    else:
        print(popcount(find(int(s)-1,int(t),0,0,d))) com=='1' com '1' update(int(s)-1,t) update int(s)-1 int(s) int s 1 t print(popcount(find(int(s)-1,int(t),0,0,d))) print popcount(find(int(s)-1,int(t),0,0,d)) popcount find(int(s)-1,int(t),0,0,d) find int(s)-1 int(s) int s 1 int(t) int t 0 0 d def initialize(N):
    i=1
    while i<N:
        i*=2
    return [0]*(2*i-1),i def initialize(N):
    i=1
    while i<N:
        i*=2
    return [0]*(2*i-1),i initialize com,s,t=map(str,input().split()) map(str,input().split()) com SEG,d=initialize(N) initialize(N) SEG d=initialize(N) initialize(N) d N=int(input()) int(input()) N t=map(str,input().split()) map(str,input().split()) t Q=int(input()) int(input()) Q def popcount(x):
    return bin(x).count('1') def popcount(x):
    return bin(x).count('1') popcount def update(i,x):
    i+=d-1
    bit=ord(x)-97
    SEG[i]=0 | (1<<bit)
    while i>0:
        i=(i-1)//2
        SEG[i]=SEG[i*2+1]|SEG[i*2+2]
         def update(i,x):
    i+=d-1
    bit=ord(x)-97
    SEG[i]=0 | (1<<bit)
    while i>0:
        i=(i-1)//2
        SEG[i]=SEG[i*2+1]|SEG[i*2+2]
         update S=input() input() S s,t=map(str,input().split()) map(str,input().split()) s def find(a,b,k,l,r):
    if r<=a or b<=l:
        return 0
    if a<=l and r<=b:
        return SEG[k]
    else:
        c1=find(a,b,2*k+1,l,(l+r)//2)
        c2=find(a,b,2*k+2,(l+r)//2,r)
        return c1|c2
         def find(a,b,k,l,r):
    if r<=a or b<=l:
        return 0
    if a<=l and r<=b:
        return SEG[k]
    else:
        c1=find(a,b,2*k+1,l,(l+r)//2)
        c2=find(a,b,2*k+2,(l+r)//2,r)
        return c1|c2
         find
def popcount(x):
    return bin(x).count('1')

def initialize(N):
    i=1
    while i<N:
        i*=2
    return [0]*(2*i-1),i

def update(i,x):
    i+=d-1
    bit=ord(x)-97
    SEG[i]=0 | (1<<bit)
    while i>0:
        i=(i-1)//2
        SEG[i]=SEG[i*2+1]|SEG[i*2+2]
        
def find(a,b,k,l,r):
    if r<=a or b<=l:
        return 0
    if a<=l and r<=b:
        return SEG[k]
    else:
        c1=find(a,b,2*k+1,l,(l+r)//2)
        c2=find(a,b,2*k+2,(l+r)//2,r)
        return c1|c2
        
N=int(input())
S=input()
Q=int(input())
SEG,d=initialize(N)
for i in range(N):
    update(i,S[i])
for i in range(Q):
    com,s,t=map(str,input().split())
    if(com=='1'):
        update(int(s)-1,t)
    else:
        print(popcount(find(int(s)-1,int(t),0,0,d)))