from bisect import bisect_left,bisect_right
import string 

dic = {c:[] for c in string.ascii_lowercase}

n = int(input())
s = list(input())
q = int(input())

for i,c in enumerate(s,start=1):
  dic[c].append(i)
  
for i in range(q):
  p,l,r = map(str,input().split())
  if p =='1':
    j = int(l)
    if r == s[j-1]:
      continue
    c = s[j-1]    
    dic[c].pop(bisect_left(dic[c],j))
    dic[r].insert(bisect_left(dic[r],j),j)
    s[j-1] = r
  else:
    ans = 0
    l = int(l)
    r = int(r)
    for c in string.ascii_lowercase:
      pl = bisect_left(dic[c],l)
      if pl < len(dic[c]):
        if dic[c][pl] <= r:
          ans += 1
    print(ans) from bisect import bisect_left,bisect_right import string string c:[] for c in string.ascii_lowercase for c in string.ascii_lowercase c string.ascii_lowercase string ascii_lowercase for c in string.ascii_lowercase c [] dic = {c:[] for c in string.ascii_lowercase} dic {c:[] for c in string.ascii_lowercase} n = int(input()) n int(input()) int input() input s = list(input()) s list(input()) list input() input q = int(input()) q int(input()) int input() input for i,c in enumerate(s,start=1):
  dic[c].append(i)
   i c enumerate(s,start=1) enumerate s start=1 start 1 dic[c].append(i) [c].append [c] dic c append i for i in range(q):
  p,l,r = map(str,input().split())
  if p =='1':
    j = int(l)
    if r == s[j-1]:
      continue
    c = s[j-1]    
    dic[c].pop(bisect_left(dic[c],j))
    dic[r].insert(bisect_left(dic[r],j),j)
    s[j-1] = r
  else:
    ans = 0
    l = int(l)
    r = int(r)
    for c in string.ascii_lowercase:
      pl = bisect_left(dic[c],l)
      if pl < len(dic[c]):
        if dic[c][pl] <= r:
          ans += 1
    print(ans) i range(q) range q p,l,r = map(str,input().split()) p map(str,input().split()) map str input().split() ().split () input split l r if p =='1':
    j = int(l)
    if r == s[j-1]:
      continue
    c = s[j-1]    
    dic[c].pop(bisect_left(dic[c],j))
    dic[r].insert(bisect_left(dic[r],j),j)
    s[j-1] = r
  else:
    ans = 0
    l = int(l)
    r = int(r)
    for c in string.ascii_lowercase:
      pl = bisect_left(dic[c],l)
      if pl < len(dic[c]):
        if dic[c][pl] <= r:
          ans += 1
    print(ans) p =='1' p '1' j = int(l) j int(l) int l if r == s[j-1]:
      continue
     r == s[j-1] r s[j-1] s j-1 j 1 continue c = s[j-1] c s[j-1] s j-1 j 1 dic[c].pop(bisect_left(dic[c],j)) [c].pop [c] dic c pop bisect_left(dic[c],j) bisect_left dic[c] dic c j dic[r].insert(bisect_left(dic[r],j),j) [r].insert [r] dic r insert bisect_left(dic[r],j) bisect_left dic[r] dic r j j s[j-1] = r s[j-1] s j-1 j 1 r ans = 0 ans 0 l = int(l) l int(l) int l r = int(r) r int(r) int r for c in string.ascii_lowercase:
      pl = bisect_left(dic[c],l)
      if pl < len(dic[c]):
        if dic[c][pl] <= r:
          ans += 1
     c string.ascii_lowercase string ascii_lowercase pl = bisect_left(dic[c],l) pl bisect_left(dic[c],l) bisect_left dic[c] dic c l if pl < len(dic[c]):
        if dic[c][pl] <= r:
          ans += 1
     pl < len(dic[c]) pl len(dic[c]) len dic[c] dic c if dic[c][pl] <= r:
          ans += 1
     dic[c][pl] <= r dic[c][pl] [c] dic c pl r ans += 1 ans 1 print(ans) print ans c = s[j-1] s[j-1] c r = int(r) int(r) r pl = bisect_left(dic[c],l) bisect_left(dic[c],l) pl s = list(input()) list(input()) s j = int(l) int(l) j r = map(str,input().split()) map(str,input().split()) r dic = {c:[] for c in string.ascii_lowercase} {c:[] for c in string.ascii_lowercase} dic n = int(input()) int(input()) n ans = 0 0 ans ans += 1 1 ans q = int(input()) int(input()) q l,r = map(str,input().split()) map(str,input().split()) l p,l,r = map(str,input().split()) map(str,input().split()) p l = int(l) int(l) l
from bisect import bisect_left,bisect_right
import string 

dic = {c:[] for c in string.ascii_lowercase}

n = int(input())
s = list(input())
q = int(input())

for i,c in enumerate(s,start=1):
  dic[c].append(i)
  
for i in range(q):
  p,l,r = map(str,input().split())
  if p =='1':
    j = int(l)
    if r == s[j-1]:
      continue
    c = s[j-1]    
    dic[c].pop(bisect_left(dic[c],j))
    dic[r].insert(bisect_left(dic[r],j),j)
    s[j-1] = r
  else:
    ans = 0
    l = int(l)
    r = int(r)
    for c in string.ascii_lowercase:
      pl = bisect_left(dic[c],l)
      if pl < len(dic[c]):
        if dic[c][pl] <= r:
          ans += 1
    print(ans)
