def main():
  import sys
  input=sys.stdin.buffer.readline
  n=int(input())
  d=[0]*n+[1<<c-97for c in input()[:n]]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  r=[]
  for _ in range(int(input())):
    q,a,b=input().split()
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    r+=bin(s).count('1'),
  print(' '.join(map(str,r)))
main() def main():
  import sys
  input=sys.stdin.buffer.readline
  n=int(input())
  d=[0]*n+[1<<c-97for c in input()[:n]]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  r=[]
  for _ in range(int(input())):
    q,a,b=input().split()
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    r+=bin(s).count('1'),
  print(' '.join(map(str,r))) main import sys sys input=sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline n=int(input()) n int(input()) int input() input 1<<c-97for c in input()[:n] for c in input()[:n] c input()[:n] () input :n n for c in input()[:n] 1<<c-97 1 c-97 c 97 d=[0]*n+[1<<c-97for c in input()[:n]] d [0]*n+[1<<c-97for c in input()[:n]] [0]*n [0] 0 n [1<<c-97for c in input()[:n]] for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
   i range(n-1,0,-1) range n-1 n 1 0 -1 r=[] r [] for _ in range(int(input())):
    q,a,b=input().split()
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    r+=bin(s).count('1'),
   _ range(int(input())) range int(input()) int input() input q,a,b=input().split() q input().split() ().split () input split a b i,s=int(a)+n-1,0 i int(a)+n-1 int(a)+n int(a) int a n 1 s 0 if q<b'2':
      d[i]=1<<b[0]-97
      while i:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
     q<b'2' q b'2' d[i]=1<<b[0]-97 d[i] d i 1<<b[0]-97 1 b[0]-97 b[0] b 0 97 while i:
        i//=2
        d[i]=d[i+i]|d[i-~i]
       i i//=2 i 2 d[i]=d[i+i]|d[i-~i] d[i] d i d[i+i]|d[i-~i] d[i+i] d i+i i i d[i-~i] d i-~i i ~i i continue j=int(b)+n j int(b)+n int(b) int b n while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
     i<j i j if i&1:
        s|=d[i]
        i+=1
       i&1 i 1 s|=d[i] s d[i] d i i+=1 i 1 if j&1:
        j-=1
        s|=d[j]
       j&1 j 1 j-=1 j 1 s|=d[j] s d[j] d j i//=2 i 2 j//=2 j 2 r+=bin(s).count('1'), r bin(s).count('1') (s).count (s) bin s count '1' print(' '.join(map(str,r))) print ' '.join(map(str,r)) ' '.join ' ' join map(str,r) map str r main() main def main():
  import sys
  input=sys.stdin.buffer.readline
  n=int(input())
  d=[0]*n+[1<<c-97for c in input()[:n]]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  r=[]
  for _ in range(int(input())):
    q,a,b=input().split()
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    r+=bin(s).count('1'),
  print(' '.join(map(str,r))) def main():
  import sys
  input=sys.stdin.buffer.readline
  n=int(input())
  d=[0]*n+[1<<c-97for c in input()[:n]]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  r=[]
  for _ in range(int(input())):
    q,a,b=input().split()
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    r+=bin(s).count('1'),
  print(' '.join(map(str,r))) main
def main():
  import sys
  input=sys.stdin.buffer.readline
  n=int(input())
  d=[0]*n+[1<<c-97for c in input()[:n]]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  r=[]
  for _ in range(int(input())):
    q,a,b=input().split()
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i&1:
        s|=d[i]
        i+=1
      if j&1:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    r+=bin(s).count('1'),
  print(' '.join(map(str,r)))
main()