import sys
input=sys.stdin.readline
n=int(input())
#print(n,end=' n')
data=[0]*(2*n)
def upd(i,x):
  i+=n
  data[i]=x
  while i>1:
    data[i>>1]=data[i]|data[i^1]
    i>>=1
def qry(l,r):
  l+=n
  r+=n
  res=0
  while l<r:
    if l&1:
      res|=data[l]
      l+=1
    if r&1:
      r-=1
      res|=data[r]
    l>>=1
    r>>=1
  return bin(res).count('1')

for i,c in enumerate(input()[:-1],n):
  data[i]=1<<(ord(c)-ord('a'))
for i in range(n-1,0,-1):
  data[i]=data[i<<1]|data[i<<1|1]
ans=[]
for _ in range(int(input())):
  q,a,b=input().split()
  if int(q)==1:
    upd(int(a)-1,1<<(ord(b)-ord('a')))
  else:
    ans.append(qry(int(a)-1,int(b)))
print('\n'.join(map(str,ans)))


 import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n=int(input()) n int(input()) int input() input data=[0]*(2*n) data [0]*(2*n) [0] 0 2*n 2 n def upd(i,x):
  i+=n
  data[i]=x
  while i>1:
    data[i>>1]=data[i]|data[i^1]
    i>>=1 upd i+=n i n data[i]=x data[i] data i x while i>1:
    data[i>>1]=data[i]|data[i^1]
    i>>=1 i>1 i 1 data[i>>1]=data[i]|data[i^1] data[i>>1] data i>>1 i 1 data[i]|data[i^1] data[i] data i data[i^1] data i^1 i 1 i>>=1 i 1 i i x x def qry(l,r):
  l+=n
  r+=n
  res=0
  while l<r:
    if l&1:
      res|=data[l]
      l+=1
    if r&1:
      r-=1
      res|=data[r]
    l>>=1
    r>>=1
  return bin(res).count('1') qry l+=n l n r+=n r n res=0 res 0 while l<r:
    if l&1:
      res|=data[l]
      l+=1
    if r&1:
      r-=1
      res|=data[r]
    l>>=1
    r>>=1
   l<r l r if l&1:
      res|=data[l]
      l+=1
     l&1 l 1 res|=data[l] res data[l] data l l+=1 l 1 if r&1:
      r-=1
      res|=data[r]
     r&1 r 1 r-=1 r 1 res|=data[r] res data[r] data r l>>=1 l 1 r>>=1 r 1 return bin(res).count('1') bin(res).count('1') (res).count (res) bin res count '1' l l r r for i,c in enumerate(input()[:-1],n):
  data[i]=1<<(ord(c)-ord('a')) i c enumerate(input()[:-1],n) enumerate input()[:-1] () input :-1 -1 n data[i]=1<<(ord(c)-ord('a')) data[i] data i 1<<(ord(c)-ord('a')) 1 ord(c)-ord('a') ord(c) ord c ord('a') ord 'a' for i in range(n-1,0,-1):
  data[i]=data[i<<1]|data[i<<1|1] i range(n-1,0,-1) range n-1 n 1 0 -1 data[i]=data[i<<1]|data[i<<1|1] data[i] data i data[i<<1]|data[i<<1|1] data[i<<1] data i<<1 i 1 data[i<<1|1] data i<<1|1 i<<1 i 1 1 ans=[] ans [] for _ in range(int(input())):
  q,a,b=input().split()
  if int(q)==1:
    upd(int(a)-1,1<<(ord(b)-ord('a')))
  else:
    ans.append(qry(int(a)-1,int(b))) _ range(int(input())) range int(input()) int input() input q,a,b=input().split() q input().split() ().split () input split a b if int(q)==1:
    upd(int(a)-1,1<<(ord(b)-ord('a')))
  else:
    ans.append(qry(int(a)-1,int(b))) int(q)==1 int(q) int q 1 upd(int(a)-1,1<<(ord(b)-ord('a'))) upd int(a)-1 int(a) int a 1 1<<(ord(b)-ord('a')) 1 ord(b)-ord('a') ord(b) ord b ord('a') ord 'a' ans.append(qry(int(a)-1,int(b))) ans.append ans append qry(int(a)-1,int(b)) qry int(a)-1 int(a) int a 1 int(b) int b print('\n'.join(map(str,ans))) print '\n'.join(map(str,ans)) '\n'.join '\n' join map(str,ans) map str ans input=sys.stdin.readline sys.stdin.readline input b=input().split() input().split() b n=int(input()) int(input()) n a,b=input().split() input().split() a def upd(i,x):
  i+=n
  data[i]=x
  while i>1:
    data[i>>1]=data[i]|data[i^1]
    i>>=1 def upd(i,x):
  i+=n
  data[i]=x
  while i>1:
    data[i>>1]=data[i]|data[i^1]
    i>>=1 upd q,a,b=input().split() input().split() q data=[0]*(2*n) [0]*(2*n) data def qry(l,r):
  l+=n
  r+=n
  res=0
  while l<r:
    if l&1:
      res|=data[l]
      l+=1
    if r&1:
      r-=1
      res|=data[r]
    l>>=1
    r>>=1
  return bin(res).count('1') def qry(l,r):
  l+=n
  r+=n
  res=0
  while l<r:
    if l&1:
      res|=data[l]
      l+=1
    if r&1:
      r-=1
      res|=data[r]
    l>>=1
    r>>=1
  return bin(res).count('1') qry ans=[] [] ans
import sys
input=sys.stdin.readline
n=int(input())
#print(n,end=' n')
data=[0]*(2*n)
def upd(i,x):
  i+=n
  data[i]=x
  while i>1:
    data[i>>1]=data[i]|data[i^1]
    i>>=1
def qry(l,r):
  l+=n
  r+=n
  res=0
  while l<r:
    if l&1:
      res|=data[l]
      l+=1
    if r&1:
      r-=1
      res|=data[r]
    l>>=1
    r>>=1
  return bin(res).count('1')

for i,c in enumerate(input()[:-1],n):
  data[i]=1<<(ord(c)-ord('a'))
for i in range(n-1,0,-1):
  data[i]=data[i<<1]|data[i<<1|1]
ans=[]
for _ in range(int(input())):
  q,a,b=input().split()
  if int(q)==1:
    upd(int(a)-1,1<<(ord(b)-ord('a')))
  else:
    ans.append(qry(int(a)-1,int(b)))
print('\n'.join(map(str,ans)))



