f=input
n,l,q=int(f()),list(f()),int(f())
B=[[0]*-~n for i in range(26)]
def S(o,i):
  s=0
  while i: s+=B[o][i]; i-=i&-i
  return s
def A(o,i,x):
  while i<=n: B[o][i]+=x; i+=i&-i
for i in range(n): A(ord(l[i])-97,i+1,1)
for i in range(q):
  a,b,c=f().split(); b=int(b)
  if a>'1': print(sum(1 for o in range(26) if S(o,int(c))-S(o,b-1)))
  else: A(ord(l[b-1])-97,b,-1); l[b-1]=c; A(ord(c)-97,b,1) f=input f input n,l,q=int(f()),list(f()),int(f()) n int(f()) int f() f l list(f()) list f() f q int(f()) int f() f [0]*-~n for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) [0]*-~n [0] 0 -~n ~n n B=[[0]*-~n for i in range(26)] B [[0]*-~n for i in range(26)] def S(o,i):
  s=0
  while i: s+=B[o][i]; i-=i&-i
  return s S s=0 s 0 while i: s+=B[o][i]; i-=i&-i
   i return s s o o i i def A(o,i,x):
  while i<=n: B[o][i]+=x; i+=i&-i A while i<=n: B[o][i]+=x; i+=i& i<=n i n o o i i x x for i in range(n): A(ord(l[i])-97,i+1,1) i range(n) range n for i in range(q):
  a,b,c=f().split(); b=int(b)
  if a>'1': print(sum(1 for o in range(26) if S(o,int(c))-S(o,b-1)))
  else: A(ord(l[b-1])-97,b,-1); l[b-1]=c; A(ord(c)-97,b,1) i range(q) range q a,b,c=f().split() a f().split() ().split () f split b c b=int(b) b int(b) int b if a>'1': print(sum(1 for o in range(26) if S(o,int(c))-S(o,b-1)))
  else: A(ord(l[b-1])-97,b,-1); l[b-1]=c; A(ord(c)-97,b,1) a>'1' a '1' B=[[0]*-~n for i in range(26)] [[0]*-~n for i in range(26)] B c=f().split() f().split() c b,c=f().split() f().split() b def A(o,i,x):
  while i<=n: B[o][i]+=x; i+=i&-i def A(o,i,x):
  while i<=n: B[o][i]+=x; i+=i&-i A l,q=int(f()),list(f()),int(f()) list(f()) l q=int(f()),list(f()),int(f()) int(f()) q a,b,c=f().split() f().split() a f=input input f n,l,q=int(f()),list(f()),int(f()) int(f()) n def S(o,i):
  s=0
  while i: s+=B[o][i]; i-=i&-i
  return s def S(o,i):
  s=0
  while i: s+=B[o][i]; i-=i&-i
  return s S b=int(b) int(b) b
f=input
n,l,q=int(f()),list(f()),int(f())
B=[[0]*-~n for i in range(26)]
def S(o,i):
  s=0
  while i: s+=B[o][i]; i-=i&-i
  return s
def A(o,i,x):
  while i<=n: B[o][i]+=x; i+=i&-i
for i in range(n): A(ord(l[i])-97,i+1,1)
for i in range(q):
  a,b,c=f().split(); b=int(b)
  if a>'1': print(sum(1 for o in range(26) if S(o,int(c))-S(o,b-1)))
  else: A(ord(l[b-1])-97,b,-1); l[b-1]=c; A(ord(c)-97,b,1)