n=int(input())
s=[*input()]
q=int(input())
# BIT
B={chr(97+i):[0]*(n+1) for i in range(26)}
def bsum(c,i):
  s=0
  while i:
    s+=B[c][i]
    i-=i&-i
  return s
def badd(c,i,x):
  while i<=n:
    B[c][i]+=x
    i+=i&-i
for i,c in enumerate(s):
  badd(c,i+1,1)
for _ in range(q):
  x,y,z=input().split()
  y=int(y)-1
  if x=='1':
    badd(s[y],y+1,-1)
    s[y]=z
    badd(z,y+1,1)
  else:
    print(sum(1 for c in B if bsum(c,int(z))-bsum(c,y))) n=int(input()) n int(input()) int input() input s=[*input()] s [*input()] *input() input() input q=int(input()) q int(input()) int input() input chr(97+i):[0]*(n+1) 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 [0]*(n+1) [0] 0 n+1 n 1 B={chr(97+i):[0]*(n+1) for i in range(26)} B {chr(97+i):[0]*(n+1) for i in range(26)} def bsum(c,i):
  s=0
  while i:
    s+=B[c][i]
    i-=i&-i
  return s bsum s=0 s 0 while i:
    s+=B[c][i]
    i-=i&-i
   i s+=B[c][i] s B[c][i] [c] B c i i-=i&-i i i&-i i -i i return s s c c i i def badd(c,i,x):
  while i<=n:
    B[c][i]+=x
    i+=i&-i badd while i<=n:
    B[c][i]+=x
    i+=i&-i i<=n i n B[c][i]+=x B[c][i] [c] B c i x i+=i&-i i i&-i i -i i c c i i x x for i,c in enumerate(s):
  badd(c,i+1,1) i c enumerate(s) enumerate s badd(c,i+1,1) badd c i+1 i 1 1 for _ in range(q):
  x,y,z=input().split()
  y=int(y)-1
  if x=='1':
    badd(s[y],y+1,-1)
    s[y]=z
    badd(z,y+1,1)
  else:
    print(sum(1 for c in B if bsum(c,int(z))-bsum(c,y))) _ range(q) range q x,y,z=input().split() x input().split() ().split () input split y z y=int(y)-1 y int(y)-1 int(y) int y 1 if x=='1':
    badd(s[y],y+1,-1)
    s[y]=z
    badd(z,y+1,1)
  else:
    print(sum(1 for c in B if bsum(c,int(z))-bsum(c,y))) x=='1' x '1' badd(s[y],y+1,-1) badd s[y] s y y+1 y 1 -1 s[y]=z s[y] s y z badd(z,y+1,1) badd z y+1 y 1 1 print(sum(1 for c in B if bsum(c,int(z))-bsum(c,y))) print sum(1 for c in B if bsum(c,int(z))-bsum(c,y)) sum 1 x,y,z=input().split() input().split() x q=int(input()) int(input()) q def bsum(c,i):
  s=0
  while i:
    s+=B[c][i]
    i-=i&-i
  return s def bsum(c,i):
  s=0
  while i:
    s+=B[c][i]
    i-=i&-i
  return s bsum B={chr(97+i):[0]*(n+1) for i in range(26)} {chr(97+i):[0]*(n+1) for i in range(26)} B y,z=input().split() input().split() y z=input().split() input().split() z y=int(y)-1 int(y)-1 y def badd(c,i,x):
  while i<=n:
    B[c][i]+=x
    i+=i&-i def badd(c,i,x):
  while i<=n:
    B[c][i]+=x
    i+=i&-i badd s=[*input()] [*input()] s n=int(input()) int(input()) n
n=int(input())
s=[*input()]
q=int(input())
# BIT
B={chr(97+i):[0]*(n+1) for i in range(26)}
def bsum(c,i):
  s=0
  while i:
    s+=B[c][i]
    i-=i&-i
  return s
def badd(c,i,x):
  while i<=n:
    B[c][i]+=x
    i+=i&-i
for i,c in enumerate(s):
  badd(c,i+1,1)
for _ in range(q):
  x,y,z=input().split()
  y=int(y)-1
  if x=='1':
    badd(s[y],y+1,-1)
    s[y]=z
    badd(z,y+1,1)
  else:
    print(sum(1 for c in B if bsum(c,int(z))-bsum(c,y)))