n=int(input())
s=[*input()]
q=int(input())
from collections import *
d=defaultdict(list)
for i,c in enumerate(s):
  d[c]+=[i]
from bisect import *
for _ in range(q):
  x,y,z=input().split()
  y=int(y)-1
  if x=='1':
    if s[y]==z: continue
    d[s[y]].pop(bisect(d[s[y]],y)-1)
    s[y]=z
    insort(d[z],y)
  else:
    print(sum(bisect(l,int(z)-1)-bisect_left(l,y)>0 for l in d.values())) 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 from collections import * d=defaultdict(list) d defaultdict(list) defaultdict list for i,c in enumerate(s):
  d[c]+=[i] i c enumerate(s) enumerate s d[c]+=[i] d[c] d c [i] i from bisect import * for _ in range(q):
  x,y,z=input().split()
  y=int(y)-1
  if x=='1':
    if s[y]==z: continue
    d[s[y]].pop(bisect(d[s[y]],y)-1)
    s[y]=z
    insort(d[z],y)
  else:
    print(sum(bisect(l,int(z)-1)-bisect_left(l,y)>0 for l in d.values())) _ 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':
    if s[y]==z: continue
    d[s[y]].pop(bisect(d[s[y]],y)-1)
    s[y]=z
    insort(d[z],y)
  else:
    print(sum(bisect(l,int(z)-1)-bisect_left(l,y)>0 for l in d.values())) x=='1' x '1' if s[y]==z: continue
     s[y]==z s[y] s y z d[s[y]].pop(bisect(d[s[y]],y)-1) [s[y]].pop [s[y]] d s[y] s y pop bisect(d[s[y]],y)-1 bisect(d[s[y]],y) bisect d[s[y]] d s[y] s y y 1 s[y]=z s[y] s y z insort(d[z],y) insort d[z] d z y print(sum(bisect(l,int(z)-1)-bisect_left(l,y)>0 for l in d.values())) print sum(bisect(l,int(z)-1)-bisect_left(l,y)>0 for l in d.values()) sum bisect(l,int(z)-1)-bisect_left(l,y)>0 bisect(l,int(z)-1)-bisect_left(l,y) bisect(l,int(z)-1) bisect l int(z)-1 int(z) int z 1 bisect_left(l,y) bisect_left l y 0 s=[*input()] [*input()] s q=int(input()) int(input()) q n=int(input()) int(input()) n d=defaultdict(list) defaultdict(list) d z=input().split() input().split() z x,y,z=input().split() input().split() x y,z=input().split() input().split() y y=int(y)-1 int(y)-1 y
n=int(input())
s=[*input()]
q=int(input())
from collections import *
d=defaultdict(list)
for i,c in enumerate(s):
  d[c]+=[i]
from bisect import *
for _ in range(q):
  x,y,z=input().split()
  y=int(y)-1
  if x=='1':
    if s[y]==z: continue
    d[s[y]].pop(bisect(d[s[y]],y)-1)
    s[y]=z
    insort(d[z],y)
  else:
    print(sum(bisect(l,int(z)-1)-bisect_left(l,y)>0 for l in d.values()))