import bisect

N=int(input())
S=list(str(input()))

def ci(x):
  return "abcdefghijklmnopqrstuvwxyz".find(x)

d=[[] for _ in range(26)]
for i,s in enumerate(S):
  d[ci(s)].append(i)

for i in range(int(input())):
  t,x,y=input().split()
  if t=="1":
    x=int(x)-1
    if S[x]!=y:
      l=bisect.bisect_left(d[ci(S[x])],x)
      d[ci(S[x])].pop(l)
      bisect.insort(d[ci(y)],x)
      S[x]=y
  else:
    x,y=int(x)-1,int(y)-1
    c=0
    for j in range(26):
      l=bisect.bisect_left(d[j],x)
      if l<len(d[j]) and d[j][l] <= y:
        c += 1
    print(c) import bisect bisect N=int(input()) N int(input()) int input() input S=list(str(input())) S list(str(input())) list str(input()) str input() input def ci(x):
  return "abcdefghijklmnopqrstuvwxyz".find(x) ci return "abcdefghijklmnopqrstuvwxyz".find(x) "abcdefghijklmnopqrstuvwxyz".find(x) "abcdefghijklmnopqrstuvwxyz".find "abcdefghijklmnopqrstuvwxyz" find x x x [] for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [] d=[[] for _ in range(26)] d [[] for _ in range(26)] for i,s in enumerate(S):
  d[ci(s)].append(i) i s enumerate(S) enumerate S d[ci(s)].append(i) [ci(s)].append [ci(s)] d ci(s) ci s append i for i in range(int(input())):
  t,x,y=input().split()
  if t=="1":
    x=int(x)-1
    if S[x]!=y:
      l=bisect.bisect_left(d[ci(S[x])],x)
      d[ci(S[x])].pop(l)
      bisect.insort(d[ci(y)],x)
      S[x]=y
  else:
    x,y=int(x)-1,int(y)-1
    c=0
    for j in range(26):
      l=bisect.bisect_left(d[j],x)
      if l<len(d[j]) and d[j][l] <= y:
        c += 1
    print(c) i range(int(input())) range int(input()) int input() input t,x,y=input().split() t input().split() ().split () input split x y if t=="1":
    x=int(x)-1
    if S[x]!=y:
      l=bisect.bisect_left(d[ci(S[x])],x)
      d[ci(S[x])].pop(l)
      bisect.insort(d[ci(y)],x)
      S[x]=y
  else:
    x,y=int(x)-1,int(y)-1
    c=0
    for j in range(26):
      l=bisect.bisect_left(d[j],x)
      if l<len(d[j]) and d[j][l] <= y:
        c += 1
    print(c) t=="1" t "1" x=int(x)-1 x int(x)-1 int(x) int x 1 if S[x]!=y:
      l=bisect.bisect_left(d[ci(S[x])],x)
      d[ci(S[x])].pop(l)
      bisect.insort(d[ci(y)],x)
      S[x]=y
   S[x]!=y S[x] S x y l=bisect.bisect_left(d[ci(S[x])],x) l bisect.bisect_left(d[ci(S[x])],x) bisect.bisect_left bisect bisect_left d[ci(S[x])] d ci(S[x]) ci S[x] S x x d[ci(S[x])].pop(l) [ci(S[x])].pop [ci(S[x])] d ci(S[x]) ci S[x] S x pop l bisect.insort(d[ci(y)],x) bisect.insort bisect insort d[ci(y)] d ci(y) ci y x S[x]=y S[x] S x y x,y=int(x)-1,int(y)-1 x int(x)-1 int(x) int x 1 y int(y)-1 int(y) int y 1 c=0 c 0 for j in range(26):
      l=bisect.bisect_left(d[j],x)
      if l<len(d[j]) and d[j][l] <= y:
        c += 1
     j range(26) range 26 l=bisect.bisect_left(d[j],x) l bisect.bisect_left(d[j],x) bisect.bisect_left bisect bisect_left d[j] d j x if l<len(d[j]) and d[j][l] <= y:
        c += 1
     l<len(d[j]) and d[j][l] <= y l<len(d[j]) l len(d[j]) len d[j] d j d[j][l] <= y d[j][l] [j] d j l y c += 1 c 1 print(c) print c t,x,y=input().split() input().split() t c=0 0 c l=bisect.bisect_left(d[ci(S[x])],x) bisect.bisect_left(d[ci(S[x])],x) l c += 1 1 c x,y=input().split() input().split() x y=input().split() input().split() y x,y=int(x)-1,int(y)-1 int(x)-1 x l=bisect.bisect_left(d[j],x) bisect.bisect_left(d[j],x) l d=[[] for _ in range(26)] [[] for _ in range(26)] d S=list(str(input())) list(str(input())) S x=int(x)-1 int(x)-1 x N=int(input()) int(input()) N y=int(x)-1,int(y)-1 int(y)-1 y def ci(x):
  return "abcdefghijklmnopqrstuvwxyz".find(x) def ci(x):
  return "abcdefghijklmnopqrstuvwxyz".find(x) ci
import bisect

N=int(input())
S=list(str(input()))

def ci(x):
  return "abcdefghijklmnopqrstuvwxyz".find(x)

d=[[] for _ in range(26)]
for i,s in enumerate(S):
  d[ci(s)].append(i)

for i in range(int(input())):
  t,x,y=input().split()
  if t=="1":
    x=int(x)-1
    if S[x]!=y:
      l=bisect.bisect_left(d[ci(S[x])],x)
      d[ci(S[x])].pop(l)
      bisect.insort(d[ci(y)],x)
      S[x]=y
  else:
    x,y=int(x)-1,int(y)-1
    c=0
    for j in range(26):
      l=bisect.bisect_left(d[j],x)
      if l<len(d[j]) and d[j][l] <= y:
        c += 1
    print(c)
