# -*- coding: utf-8 -*-
import sys
N=input()
bit=[ [ 0 for _ in range(N+1) ] for __ in range(27) ] 

def add(i,a,w):
    while a<=N:
        bit[i][a]+=w
        a+=a&-a

def sum(i,a):
    ret=0
    while 0<a:
        ret+=bit[i][a]
        a-=a&-a
    return ret

S=sys.stdin.readline().strip()
S=[None]+list(S) #1-indexed
for j,x in enumerate(S):
    if j==0: continue
    i=ord(x)-96
    add(i,j,1)

Q=input()
for _ in range(Q):
    q1,q2,q3=sys.stdin.readline().split()
    if q1=="1":
        q1=int(q1)
        q2=int(q2)
        current_s=q3
        former_s=S[q2]
        former_s=ord(former_s)-96  #1-indexed
        S[q2]=current_s         #文字列で更新された1文字を置き換える
        current_s=ord(current_s)-96
        add(current_s,q2,1)
        add(former_s,q2,-1) 
    if q1=="2":
        q2=int(q2)
        q3=int(q3)
        begin,end=q2,q3
        cnt=0
        for i in range(1,27):
            if 0<sum(i,end)-sum(i,begin-1):
                cnt+=1
        print cnt import sys sys N=input() N input() input [ 0 for _ in range(N+1) ] for __ in range(27) for __ in range(27) __ range(27) range 27 for __ in range(27) [ 0 for _ in range(N+1) ] bit=[ [ 0 for _ in range(N+1) ] for __ in range(27) ] bit [ [ 0 for _ in range(N+1) ] for __ in range(27) ] def add(i,a,w):
    while a<=N:
        bit[i][a]+=w
        a+=a&-a add while a<=N:
        bit[i][a]+=w
        a+=a&-a a<=N a N bit[i][a]+=w bit[i][a] [i] bit i a w a+=a&-a a a&-a a -a a i i a a w w def sum(i,a):
    ret=0
    while 0<a:
        ret+=bit[i][a]
        a-=a&-a
    return ret sum ret=0 ret 0 while 0<a:
        ret+=bit[i][a]
        a-=a&-a
     0<a 0 a ret+=bit[i][a] ret bit[i][a] [i] bit i a a-=a&-a a a&-a a -a a return ret ret i i a a S=sys.stdin.readline().strip() S sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip S=[None]+list(S) S [None]+list(S) [None] None list(S) list S for j,x in enumerate(S):
    if j==0: continue
    i=ord(x)-96
    add(i,j,1) j x enumerate(S) enumerate S if j==0: continue
     j==0 j 0 i=ord(x)-96 i ord(x)-96 ord(x) ord x 96 add(i,j,1) add i j 1 Q=input() Q input() input for _ in range(Q):
    q1,q2,q3=sys.stdin.readline().split()
    if q1=="1":
        q1=int(q1)
        q2=int(q2)
        current_s=q3
        former_s=S[q2]
        former_s=ord(former_s)-96  #1-indexed
        S[q2]=current_s         #文字列で更新された1文字を置き換える
        current_s=ord(current_s)-96
        add(current_s,q2,1)
        add(former_s,q2,-1) 
    if q1=="2":
        q2=int(q2)
        q3=int(q3)
        begin,end=q2,q3
        cnt=0
        for i in range(1,27):
            if 0<sum(i,end)-sum(i,begin-1):
                cnt+=1
        print cnt _ range(Q) range Q q1,q2,q3=sys.stdin.readline().split() q1 sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split q2 q3 if q1=="1":
        q1=int(q1)
        q2=int(q2)
        current_s=q3
        former_s=S[q2]
        former_s=ord(former_s)-96  #1-indexed
        S[q2]=current_s         #文字列で更新された1文字を置き換える
        current_s=ord(current_s)-96
        add(current_s,q2,1)
        add(former_s,q2,-1) 
     q1=="1" q1 "1" q1=int(q1) q1 int(q1) int q1 q2=int(q2) q2 int(q2) int q2 current_s=q3 current_s q3 former_s=S[q2] former_s S[q2] S q2 former_s=ord(former_s)-96 former_s ord(former_s)-96 ord(former_s) ord former_s 96 S[q2]=current_s S[q2] S q2 current_s current_s=ord(current_s)-96 current_s ord(current_s)-96 ord(current_s) ord current_s 96 add(current_s,q2,1) add current_s q2 1 add(former_s,q2,-1) add former_s q2 -1 if q1=="2":
        q2=int(q2)
        q3=int(q3)
        begin,end=q2,q3
        cnt=0
        for i in range(1,27):
            if 0<sum(i,end)-sum(i,begin-1):
                cnt+=1
        print cnt q1=="2" q1 "2" q2=int(q2) q2 int(q2) int q2 q3=int(q3) q3 int(q3) int q3 begin,end=q2,q3 begin q2 end q3 cnt=0 cnt 0 for i in range(1,27):
            if 0<sum(i,end)-sum(i,begin-1):
                cnt+=1
         i range(1,27) range 1 27 if 0<sum(i,end)-sum(i,begin-1):
                cnt+=1
         0<sum(i,end)-sum(i,begin-1) 0 sum(i,end)-sum(i,begin-1) sum(i,end) sum i end sum(i,begin-1) sum i begin-1 begin 1 cnt+=1 cnt 1 print def add(i,a,w):
    while a<=N:
        bit[i][a]+=w
        a+=a&-a def add(i,a,w):
    while a<=N:
        bit[i][a]+=w
        a+=a&-a add begin,end=q2,q3 q2 begin def sum(i,a):
    ret=0
    while 0<a:
        ret+=bit[i][a]
        a-=a&-a
    return ret def sum(i,a):
    ret=0
    while 0<a:
        ret+=bit[i][a]
        a-=a&-a
    return ret sum q1=int(q1) int(q1) q1 q2=int(q2) int(q2) q2 q1,q2,q3=sys.stdin.readline().split() sys.stdin.readline().split() q1 q3=sys.stdin.readline().split() sys.stdin.readline().split() q3 q3=int(q3) int(q3) q3 bit=[ [ 0 for _ in range(N+1) ] for __ in range(27) ] [ [ 0 for _ in range(N+1) ] for __ in range(27) ] bit former_s=ord(former_s)-96 ord(former_s)-96 former_s current_s=ord(current_s)-96 ord(current_s)-96 current_s S=[None]+list(S) [None]+list(S) S former_s=S[q2] S[q2] former_s S=sys.stdin.readline().strip() sys.stdin.readline().strip() S current_s=q3 q3 current_s q2=int(q2) int(q2) q2 q2,q3=sys.stdin.readline().split() sys.stdin.readline().split() q2 Q=input() input() Q cnt=0 0 cnt N=input() input() N cnt+=1 1 cnt i=ord(x)-96 ord(x)-96 i end=q2,q3 q3 end
# -*- coding: utf-8 -*-
import sys
N=input()
bit=[ [ 0 for _ in range(N+1) ] for __ in range(27) ] 

def add(i,a,w):
    while a<=N:
        bit[i][a]+=w
        a+=a&-a

def sum(i,a):
    ret=0
    while 0<a:
        ret+=bit[i][a]
        a-=a&-a
    return ret

S=sys.stdin.readline().strip()
S=[None]+list(S) #1-indexed
for j,x in enumerate(S):
    if j==0: continue
    i=ord(x)-96
    add(i,j,1)

Q=input()
for _ in range(Q):
    q1,q2,q3=sys.stdin.readline().split()
    if q1=="1":
        q1=int(q1)
        q2=int(q2)
        current_s=q3
        former_s=S[q2]
        former_s=ord(former_s)-96  #1-indexed
        S[q2]=current_s         #文字列で更新された1文字を置き換える
        current_s=ord(current_s)-96
        add(current_s,q2,1)
        add(former_s,q2,-1) 
    if q1=="2":
        q2=int(q2)
        q3=int(q3)
        begin,end=q2,q3
        cnt=0
        for i in range(1,27):
            if 0<sum(i,end)-sum(i,begin-1):
                cnt+=1
        print cnt