def main():
  import sys
  n,s,_,*t=sys.stdin.buffer.read().split()
  n=int(n)
  d=[0]*n+[1<<c-97for c in s]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  for q,a,b in zip(*[iter(t)]*3):
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    print(bin(s).count('1'),flush=False)
main() def main():
  import sys
  n,s,_,*t=sys.stdin.buffer.read().split()
  n=int(n)
  d=[0]*n+[1<<c-97for c in s]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  for q,a,b in zip(*[iter(t)]*3):
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    print(bin(s).count('1'),flush=False) main import sys sys n,s,_,*t=sys.stdin.buffer.read().split() n sys.stdin.buffer.read().split() sys.stdin.buffer.read().split sys.stdin.buffer.read() sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read split s _ *t t n=int(n) n int(n) int n 1<<c-97for c in s for c in s c s for c in s 1<<c-97 1 c-97 c 97 d=[0]*n+[1<<c-97for c in s] d [0]*n+[1<<c-97for c in s] [0]*n [0] 0 n [1<<c-97for c in s] for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
   i range(n-1,0,-1) range n-1 n 1 0 -1 for q,a,b in zip(*[iter(t)]*3):
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    print(bin(s).count('1'),flush=False) q a b zip(*[iter(t)]*3) zip *[iter(t)]*3 [iter(t)]*3 [iter(t)] iter(t) iter t 3 i,s=int(a)+n-1,0 i int(a)+n-1 int(a)+n int(a) int a n 1 s 0 if q<b'2':
      d[i]=1<<b[0]-97
      while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
     q<b'2' q b'2' d[i]=1<<b[0]-97 d[i] d i 1<<b[0]-97 1 b[0]-97 b[0] b 0 97 while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
       i>1 i 1 i//=2 i 2 d[i]=d[i+i]|d[i-~i] d[i] d i d[i+i]|d[i-~i] d[i+i] d i+i i i d[i-~i] d i-~i i ~i i continue j=int(b)+n j int(b)+n int(b) int b n while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
     i<j i j if i&1:
        s|=d[i]
        i+=1
       i&1 i 1 s|=d[i] s d[i] d i i+=1 i 1 if j&1:
        j-=1
        s|=d[j]
       j&1 j 1 j-=1 j 1 s|=d[j] s d[j] d j i//=2 i 2 j//=2 j 2 print(bin(s).count('1'),flush=False) print bin(s).count('1') (s).count (s) bin s count '1' flush=False flush False main() main def main():
  import sys
  n,s,_,*t=sys.stdin.buffer.read().split()
  n=int(n)
  d=[0]*n+[1<<c-97for c in s]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  for q,a,b in zip(*[iter(t)]*3):
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    print(bin(s).count('1'),flush=False) def main():
  import sys
  n,s,_,*t=sys.stdin.buffer.read().split()
  n=int(n)
  d=[0]*n+[1<<c-97for c in s]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  for q,a,b in zip(*[iter(t)]*3):
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    print(bin(s).count('1'),flush=False) main
def main():
  import sys
  n,s,_,*t=sys.stdin.buffer.read().split()
  n=int(n)
  d=[0]*n+[1<<c-97for c in s]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  for q,a,b in zip(*[iter(t)]*3):
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i>1:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    print(bin(s).count('1'),flush=False)
main()