from bisect import bisect_left,insort_left
n=int(input())
s=list(input())
lindex=[[] for _ in range(26)]
for i in range(n):
  lindex[ord(s[i])-97].append(i)
q=int(input())
for i in range(q):
  q1,q2,q3=input().split()
  if q1=='1':
    q2=int(q2)-1
    idx=bisect_left(lindex[ord(s[q2])-97],q2)
    if s[q2]!=q3:
      del lindex[ord(s[q2])-97][idx]
      insort_left(lindex[ord(q3)-97],q2)
      s[q2]=q3
  else:
    l=int(q2)-1
    r=int(q3)-1
    cnt=0
    for j in range(26):
      if len(lindex[j])==0:
        continue
      idx=bisect_left(lindex[j],l)
      if len(lindex[j])>idx and lindex[j][idx]<=r:
        cnt+=1
    print(cnt) from bisect import bisect_left,insort_left n=int(input()) n int(input()) int input() input s=list(input()) s list(input()) list input() input [] for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [] lindex=[[] for _ in range(26)] lindex [[] for _ in range(26)] for i in range(n):
  lindex[ord(s[i])-97].append(i) i range(n) range n lindex[ord(s[i])-97].append(i) [ord(s[i])-97].append [ord(s[i])-97] lindex ord(s[i])-97 ord(s[i]) ord s[i] s i 97 append i q=int(input()) q int(input()) int input() input for i in range(q):
  q1,q2,q3=input().split()
  if q1=='1':
    q2=int(q2)-1
    idx=bisect_left(lindex[ord(s[q2])-97],q2)
    if s[q2]!=q3:
      del lindex[ord(s[q2])-97][idx]
      insort_left(lindex[ord(q3)-97],q2)
      s[q2]=q3
  else:
    l=int(q2)-1
    r=int(q3)-1
    cnt=0
    for j in range(26):
      if len(lindex[j])==0:
        continue
      idx=bisect_left(lindex[j],l)
      if len(lindex[j])>idx and lindex[j][idx]<=r:
        cnt+=1
    print(cnt) i range(q) range q q1,q2,q3=input().split() q1 input().split() ().split () input split q2 q3 if q1=='1':
    q2=int(q2)-1
    idx=bisect_left(lindex[ord(s[q2])-97],q2)
    if s[q2]!=q3:
      del lindex[ord(s[q2])-97][idx]
      insort_left(lindex[ord(q3)-97],q2)
      s[q2]=q3
  else:
    l=int(q2)-1
    r=int(q3)-1
    cnt=0
    for j in range(26):
      if len(lindex[j])==0:
        continue
      idx=bisect_left(lindex[j],l)
      if len(lindex[j])>idx and lindex[j][idx]<=r:
        cnt+=1
    print(cnt) q1=='1' q1 '1' q2=int(q2)-1 q2 int(q2)-1 int(q2) int q2 1 idx=bisect_left(lindex[ord(s[q2])-97],q2) idx bisect_left(lindex[ord(s[q2])-97],q2) bisect_left lindex[ord(s[q2])-97] lindex ord(s[q2])-97 ord(s[q2]) ord s[q2] s q2 97 q2 if s[q2]!=q3:
      del lindex[ord(s[q2])-97][idx]
      insort_left(lindex[ord(q3)-97],q2)
      s[q2]=q3
   s[q2]!=q3 s[q2] s q2 q3 del lindex[ord(s[q2])-97][idx] lindex[ord(s[q2])-97][idx] [ord(s[q2])-97] lindex ord(s[q2])-97 ord(s[q2]) ord s[q2] s q2 97 idx insort_left(lindex[ord(q3)-97],q2) insort_left lindex[ord(q3)-97] lindex ord(q3)-97 ord(q3) ord q3 97 q2 s[q2]=q3 s[q2] s q2 q3 l=int(q2)-1 l int(q2)-1 int(q2) int q2 1 r=int(q3)-1 r int(q3)-1 int(q3) int q3 1 cnt=0 cnt 0 for j in range(26):
      if len(lindex[j])==0:
        continue
      idx=bisect_left(lindex[j],l)
      if len(lindex[j])>idx and lindex[j][idx]<=r:
        cnt+=1
     j range(26) range 26 if len(lindex[j])==0:
        continue
       len(lindex[j])==0 len(lindex[j]) len lindex[j] lindex j 0 continue idx=bisect_left(lindex[j],l) idx bisect_left(lindex[j],l) bisect_left lindex[j] lindex j l if len(lindex[j])>idx and lindex[j][idx]<=r:
        cnt+=1
     len(lindex[j])>idx and lindex[j][idx]<=r len(lindex[j])>idx len(lindex[j]) len lindex[j] lindex j idx lindex[j][idx]<=r lindex[j][idx] [j] lindex j idx r cnt+=1 cnt 1 print(cnt) print cnt q2,q3=input().split() input().split() q2 q=int(input()) int(input()) q r=int(q3)-1 int(q3)-1 r n=int(input()) int(input()) n q3=input().split() input().split() q3 lindex=[[] for _ in range(26)] [[] for _ in range(26)] lindex l=int(q2)-1 int(q2)-1 l cnt=0 0 cnt cnt+=1 1 cnt idx=bisect_left(lindex[ord(s[q2])-97],q2) bisect_left(lindex[ord(s[q2])-97],q2) idx s=list(input()) list(input()) s q1,q2,q3=input().split() input().split() q1 q2=int(q2)-1 int(q2)-1 q2 idx=bisect_left(lindex[j],l) bisect_left(lindex[j],l) idx
from bisect import bisect_left,insort_left
n=int(input())
s=list(input())
lindex=[[] for _ in range(26)]
for i in range(n):
  lindex[ord(s[i])-97].append(i)
q=int(input())
for i in range(q):
  q1,q2,q3=input().split()
  if q1=='1':
    q2=int(q2)-1
    idx=bisect_left(lindex[ord(s[q2])-97],q2)
    if s[q2]!=q3:
      del lindex[ord(s[q2])-97][idx]
      insort_left(lindex[ord(q3)-97],q2)
      s[q2]=q3
  else:
    l=int(q2)-1
    r=int(q3)-1
    cnt=0
    for j in range(26):
      if len(lindex[j])==0:
        continue
      idx=bisect_left(lindex[j],l)
      if len(lindex[j])>idx and lindex[j][idx]<=r:
        cnt+=1
    print(cnt)