f=input
n,s,q=int(f()),list(f()),int(f())
d={chr(97+i):[] for i in range(26)}
for i in range(n):
  d[s[i]]+=[i]
from bisect import *
for i in range(q):
  a,b,c=f().split()
  b=int(b)-1
  if a=='1':
    if s[b]==c: continue
    d[s[b]].pop(bisect(d[s[b]],b)-1)
    s[b]=c
    insort(d[c],b)
  else:
    t=0
    for l in d.values():
      m=bisect(l,b-1)
      if m<len(l) and l[m]<int(c): t+=1
    print(t) f=input f input n,s,q=int(f()),list(f()),int(f()) n int(f()) int f() f s list(f()) list f() f q int(f()) int f() f chr(97+i):[] for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) chr(97+i) chr 97+i 97 i [] d={chr(97+i):[] for i in range(26)} d {chr(97+i):[] for i in range(26)} for i in range(n):
  d[s[i]]+=[i] i range(n) range n d[s[i]]+=[i] d[s[i]] d s[i] s i [i] i from bisect import * for i in range(q):
  a,b,c=f().split()
  b=int(b)-1
  if a=='1':
    if s[b]==c: continue
    d[s[b]].pop(bisect(d[s[b]],b)-1)
    s[b]=c
    insort(d[c],b)
  else:
    t=0
    for l in d.values():
      m=bisect(l,b-1)
      if m<len(l) and l[m]<int(c): t+=1
    print(t) i range(q) range q a,b,c=f().split() a f().split() ().split () f split b c b=int(b)-1 b int(b)-1 int(b) int b 1 if a=='1':
    if s[b]==c: continue
    d[s[b]].pop(bisect(d[s[b]],b)-1)
    s[b]=c
    insort(d[c],b)
  else:
    t=0
    for l in d.values():
      m=bisect(l,b-1)
      if m<len(l) and l[m]<int(c): t+=1
    print(t) a=='1' a '1' if s[b]==c: continue
     s[b]==c s[b] s b c d[s[b]].pop(bisect(d[s[b]],b)-1) [s[b]].pop [s[b]] d s[b] s b pop bisect(d[s[b]],b)-1 bisect(d[s[b]],b) bisect d[s[b]] d s[b] s b b 1 s[b]=c s[b] s b c insort(d[c],b) insort d[c] d c b t=0 t 0 for l in d.values():
      m=bisect(l,b-1)
      if m<len(l) and l[m]<int(c): t+=1
     l d.values() d.values d values m=bisect(l,b-1) m bisect(l,b-1) bisect l b-1 b 1 if m<len(l) and l[m]<int(c): t+=1
     m<len(l) and l[m]<int(c) m<len(l) m len(l) len l l[m]<int(c) l[m] l m int(c) int c print(t) print t c=f().split() f().split() c a,b,c=f().split() f().split() a m=bisect(l,b-1) bisect(l,b-1) m s,q=int(f()),list(f()),int(f()) list(f()) s d={chr(97+i):[] for i in range(26)} {chr(97+i):[] for i in range(26)} d b=int(b)-1 int(b)-1 b n,s,q=int(f()),list(f()),int(f()) int(f()) n q=int(f()),list(f()),int(f()) int(f()) q f=input input f t=0 0 t b,c=f().split() f().split() b
f=input
n,s,q=int(f()),list(f()),int(f())
d={chr(97+i):[] for i in range(26)}
for i in range(n):
  d[s[i]]+=[i]
from bisect import *
for i in range(q):
  a,b,c=f().split()
  b=int(b)-1
  if a=='1':
    if s[b]==c: continue
    d[s[b]].pop(bisect(d[s[b]],b)-1)
    s[b]=c
    insort(d[c],b)
  else:
    t=0
    for l in d.values():
      m=bisect(l,b-1)
      if m<len(l) and l[m]<int(c): t+=1
    print(t)