import sys;input=sys.stdin.readline
n=int(input())
s=input()
num=2**(n-1).bit_length()
def segfunc(x,y):return x|y
seg=[0]*(2*num-1)
for i in range(n):seg[i+num-1]=2**(ord(s[i])-97)
for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])
def update(i,x):
  i+=num-1;seg[i]=x
  while i:i=(i-1)//2;seg[i]=segfunc(seg[i*2+1],seg[i*2+2])
def query(l,r):
  l+=num-1;r+=num-1
  if l==r:return seg[l]
  s=seg[l];l+=1
  while r-l>1:
    if ~l%2:s=segfunc(seg[l],s)
    if r%2:s=segfunc(seg[r],s);r-=1
    l//=2;r=(r-1)//2
  if l==r:return segfunc(s,seg[l])
  return segfunc(s,segfunc(seg[l],seg[r]))
for _ in range(int(input())):
  quer=input().split()
  if quer[0]=="1":
    _,i,c=quer
    update(int(i)-1,2**(ord(c)-97))
  else:
    _,l,r=quer
    print(sum(map(int,bin(query(int(l)-1,int(r)-1))[2:]))) import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n=int(input()) n int(input()) int input() input s=input() s input() input num=2**(n-1).bit_length() num 2**(n-1).bit_length() 2 (n-1).bit_length() n-1).bit_length n-1 n 1 bit_length def segfunc(x,y):return x|y segfunc x x y y seg=[0]*(2*num-1) seg [0]*(2*num-1) [0] 0 2*num-1 2*num 2 num 1 for i in range(n):seg[i+num-1]=2**(ord(s[i])-97) i range(n) range n for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) i range(num-2,-1,-1) range num-2 num 2 -1 -1 def update(i,x):
  i+=num-1;seg[i]=x
  while i:i=(i-1)//2;seg[i]=segfunc(seg[i*2+1],seg[i*2+2]) update i+=num-1 i num-1 num 1 seg[i]=x seg[i] seg i x while i:i=(i-1)//2;seg[i]=segfunc(seg[i*2+1],seg[i*2+2 i i i x x def query(l,r):
  l+=num-1;r+=num-1
  if l==r:return seg[l]
  s=seg[l];l+=1
  while r-l>1:
    if ~l%2:s=segfunc(seg[l],s)
    if r%2:s=segfunc(seg[r],s);r-=1
    l//=2;r=(r-1)//2
  if l==r:return segfunc(s,seg[l])
  return segfunc(s,segfunc(seg[l],seg[r])) query l+=num-1 l num-1 num 1 r+=num-1 r num-1 num 1 if l==r:return seg[l]
   l==r l r s=seg[l] s seg[l] seg l l+=1 l 1 while r-l>1:
    if ~l%2:s=segfunc(seg[l],s)
    if r%2:s=segfunc(seg[r],s);r-=1
    l//=2;r=(r-1)//2
   r-l>1 r-l r l 1 if ~l%2:s=segfunc(seg[l],s)
     ~l%2 ~l l 2 if r%2:s=segfunc(seg[r],s);r-=1
     r%2 r 2 l//=2 l 2 r=(r-1)//2 r (r-1)//2 r-1 r 1 2 if l==r:return segfunc(s,seg[l])
   l==r l r return segfunc(s,segfunc(seg[l],seg[r])) segfunc(s,segfunc(seg[l],seg[r])) segfunc s segfunc(seg[l],seg[r]) segfunc seg[l] seg l seg[r] seg r l l r r for _ in range(int(input())):
  quer=input().split()
  if quer[0]=="1":
    _,i,c=quer
    update(int(i)-1,2**(ord(c)-97))
  else:
    _,l,r=quer
    print(sum(map(int,bin(query(int(l)-1,int(r)-1))[2:]))) _ range(int(input())) range int(input()) int input() input quer=input().split() quer input().split() ().split () input split if quer[0]=="1":
    _,i,c=quer
    update(int(i)-1,2**(ord(c)-97))
  else:
    _,l,r=quer
    print(sum(map(int,bin(query(int(l)-1,int(r)-1))[2:]))) quer[0]=="1" quer[0] quer 0 "1" _,i,c=quer _ quer i c update(int(i)-1,2**(ord(c)-97)) update int(i)-1 int(i) int i 1 2**(ord(c)-97) 2 ord(c)-97 ord(c) ord c 97 _,l,r=quer _ quer l r print(sum(map(int,bin(query(int(l)-1,int(r)-1))[2:]))) print sum(map(int,bin(query(int(l)-1,int(r)-1))[2:])) sum map(int,bin(query(int(l)-1,int(r)-1))[2:]) map int bin(query(int(l)-1,int(r)-1))[2:] (query(int(l)-1,int(r)-1)) bin query(int(l)-1,int(r)-1) query int(l)-1 int(l) int l 1 int(r)-1 int(r) int r 1 2: 2 def segfunc(x,y):return x|y def segfunc(x,y):return x|y segfunc i,c=quer quer i def update(i,x):
  i+=num-1;seg[i]=x
  while i:i=(i-1)//2;seg[i]=segfunc(seg[i*2+1],seg[i*2+2]) def update(i,x):
  i+=num-1;seg[i]=x
  while i:i=(i-1)//2;seg[i]=segfunc(seg[i*2+1],seg[i*2+2]) update c=quer quer c r=quer quer r input=sys.stdin.readline sys.stdin.readline input def query(l,r):
  l+=num-1;r+=num-1
  if l==r:return seg[l]
  s=seg[l];l+=1
  while r-l>1:
    if ~l%2:s=segfunc(seg[l],s)
    if r%2:s=segfunc(seg[r],s);r-=1
    l//=2;r=(r-1)//2
  if l==r:return segfunc(s,seg[l])
  return segfunc(s,segfunc(seg[l],seg[r])) def query(l,r):
  l+=num-1;r+=num-1
  if l==r:return seg[l]
  s=seg[l];l+=1
  while r-l>1:
    if ~l%2:s=segfunc(seg[l],s)
    if r%2:s=segfunc(seg[r],s);r-=1
    l//=2;r=(r-1)//2
  if l==r:return segfunc(s,seg[l])
  return segfunc(s,segfunc(seg[l],seg[r])) query l,r=quer quer l _,l,r=quer quer _ quer=input().split() input().split() quer num=2**(n-1).bit_length() 2**(n-1).bit_length() num n=int(input()) int(input()) n s=input() input() s seg=[0]*(2*num-1) [0]*(2*num-1) seg _,i,c=quer quer _
import sys;input=sys.stdin.readline
n=int(input())
s=input()
num=2**(n-1).bit_length()
def segfunc(x,y):return x|y
seg=[0]*(2*num-1)
for i in range(n):seg[i+num-1]=2**(ord(s[i])-97)
for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])
def update(i,x):
  i+=num-1;seg[i]=x
  while i:i=(i-1)//2;seg[i]=segfunc(seg[i*2+1],seg[i*2+2])
def query(l,r):
  l+=num-1;r+=num-1
  if l==r:return seg[l]
  s=seg[l];l+=1
  while r-l>1:
    if ~l%2:s=segfunc(seg[l],s)
    if r%2:s=segfunc(seg[r],s);r-=1
    l//=2;r=(r-1)//2
  if l==r:return segfunc(s,seg[l])
  return segfunc(s,segfunc(seg[l],seg[r]))
for _ in range(int(input())):
  quer=input().split()
  if quer[0]=="1":
    _,i,c=quer
    update(int(i)-1,2**(ord(c)-97))
  else:
    _,l,r=quer
    print(sum(map(int,bin(query(int(l)-1,int(r)-1))[2:])))