def segfunc(x,y):
  return set(x)|set(y)
ide_ele=set()
class SegTree():
  def __init__(self,init_val,segfunc,ide_ele):
    n=len(init_val)
    self.segfunc=segfunc
    self.ide_ele=ide_ele
    self.num=1<<(n-1).bit_length()
    self.tree=[ide_ele]*2*self.num
    for i in range(n):
      self.tree[self.num+i]=init_val[i]
    for i in range(self.num-1,0,-1):
      self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1])
  def update(self,k,x):
    k+=self.num
    self.tree[k]=x
    while k>1:
      self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1])
      k>>=1
  def query(self,l,r):
    res=self.ide_ele
    l+=self.num
    r+=self.num
    while l<r:
      if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
      if r&1:
        res=self.segfunc(res,self.tree[r-1])
      l>>=1
      r>>=1
    return res
n=int(input())
s=input()
q=int(input())
st=SegTree(s,segfunc,ide_ele)
for _ in range(q):
  q,c,r=input().split()
  if q=='1':st.update(int(c)-1,r)
  else:print(len(st.query(int(c)-1,int(r)))) def segfunc(x,y):
  return set(x)|set(y) segfunc return set(x)|set(y) set(x)|set(y) set(x) set x set(y) set y x x y y ide_ele=set() ide_ele set() set class SegTree():
  def __init__(self,init_val,segfunc,ide_ele):
    n=len(init_val)
    self.segfunc=segfunc
    self.ide_ele=ide_ele
    self.num=1<<(n-1).bit_length()
    self.tree=[ide_ele]*2*self.num
    for i in range(n):
      self.tree[self.num+i]=init_val[i]
    for i in range(self.num-1,0,-1):
      self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1])
  def update(self,k,x):
    k+=self.num
    self.tree[k]=x
    while k>1:
      self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1])
      k>>=1
  def query(self,l,r):
    res=self.ide_ele
    l+=self.num
    r+=self.num
    while l<r:
      if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
      if r&1:
        res=self.segfunc(res,self.tree[r-1])
      l>>=1
      r>>=1
    return res SegTree def __init__(self,init_val,segfunc,ide_ele):
    n=len(init_val)
    self.segfunc=segfunc
    self.ide_ele=ide_ele
    self.num=1<<(n-1).bit_length()
    self.tree=[ide_ele]*2*self.num
    for i in range(n):
      self.tree[self.num+i]=init_val[i]
    for i in range(self.num-1,0,-1):
      self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1])
   __init__ n=len(init_val) n len(init_val) len init_val self.segfunc=segfunc self.segfunc self segfunc segfunc self.ide_ele=ide_ele self.ide_ele self ide_ele ide_ele self.num=1<<(n-1).bit_length() self.num self num 1<<(n-1).bit_length() 1 (n-1).bit_length() n-1).bit_length n-1 n 1 bit_length self.tree=[ide_ele]*2*self.num self.tree self tree [ide_ele]*2*self.num [ide_ele]*2 [ide_ele] ide_ele 2 self.num self num for i in range(n):
      self.tree[self.num+i]=init_val[i]
     i range(n) range n self.tree[self.num+i]=init_val[i] self.tree[self.num+i] self.tree self tree self.num+i self.num self num i init_val[i] init_val i for i in range(self.num-1,0,-1):
      self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1])
   i range(self.num-1,0,-1) range self.num-1 self.num self num 1 0 -1 self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1]) self.tree[i] self.tree self tree i self.segfunc(self.tree[2*i], self.tree[2*i+1]) self.segfunc self segfunc self.tree[2*i] self.tree self tree 2*i 2 i self.tree[2*i+1] self.tree self tree 2*i+1 2*i 2 i 1 self self init_val init_val segfunc segfunc ide_ele ide_ele def update(self,k,x):
    k+=self.num
    self.tree[k]=x
    while k>1:
      self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1])
      k>>=1
   update k+=self.num k self.num self num self.tree[k]=x self.tree[k] self.tree self tree k x while k>1:
      self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1])
      k>>=1
   k>1 k 1 self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1]) self.tree[k>>1] self.tree self tree k>>1 k 1 self.segfunc(self.tree[k],self.tree[k^1]) self.segfunc self segfunc self.tree[k] self.tree self tree k self.tree[k^1] self.tree self tree k^1 k 1 k>>=1 k 1 self self k k x x def query(self,l,r):
    res=self.ide_ele
    l+=self.num
    r+=self.num
    while l<r:
      if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
      if r&1:
        res=self.segfunc(res,self.tree[r-1])
      l>>=1
      r>>=1
    return res query res=self.ide_ele res self.ide_ele self ide_ele l+=self.num l self.num self num r+=self.num r self.num self num while l<r:
      if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
      if r&1:
        res=self.segfunc(res,self.tree[r-1])
      l>>=1
      r>>=1
     l<r l r if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
       l&1 l 1 res=self.segfunc(res,self.tree[l]) res self.segfunc(res,self.tree[l]) self.segfunc self segfunc res self.tree[l] self.tree self tree l l+=1 l 1 if r&1:
        res=self.segfunc(res,self.tree[r-1])
       r&1 r 1 res=self.segfunc(res,self.tree[r-1]) res self.segfunc(res,self.tree[r-1]) self.segfunc self segfunc res self.tree[r-1] self.tree self tree r-1 r 1 l>>=1 l 1 r>>=1 r 1 return res res self self l l r r n=int(input()) n int(input()) int input() input s=input() s input() input q=int(input()) q int(input()) int input() input st=SegTree(s,segfunc,ide_ele) st SegTree(s,segfunc,ide_ele) SegTree s segfunc ide_ele for _ in range(q):
  q,c,r=input().split()
  if q=='1':st.update(int(c)-1,r)
  else:print(len(st.query(int(c)-1,int(r)))) _ range(q) range q q,c,r=input().split() q input().split() ().split () input split c r if q=='1':st.update(int(c)-1,r)
  else:print(len(st.query(int(c)-1,int(r)))) q=='1' q '1' def segfunc(x,y):
  return set(x)|set(y) def segfunc(x,y):
  return set(x)|set(y) segfunc c,r=input().split() input().split() c s=input() input() s st=SegTree(s,segfunc,ide_ele) SegTree(s,segfunc,ide_ele) st q=int(input()) int(input()) q ide_ele=set() set() ide_ele n=int(input()) int(input()) n r=input().split() input().split() r class SegTree():
  def __init__(self,init_val,segfunc,ide_ele):
    n=len(init_val)
    self.segfunc=segfunc
    self.ide_ele=ide_ele
    self.num=1<<(n-1).bit_length()
    self.tree=[ide_ele]*2*self.num
    for i in range(n):
      self.tree[self.num+i]=init_val[i]
    for i in range(self.num-1,0,-1):
      self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1])
  def update(self,k,x):
    k+=self.num
    self.tree[k]=x
    while k>1:
      self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1])
      k>>=1
  def query(self,l,r):
    res=self.ide_ele
    l+=self.num
    r+=self.num
    while l<r:
      if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
      if r&1:
        res=self.segfunc(res,self.tree[r-1])
      l>>=1
      r>>=1
    return res class SegTree():
  def __init__(self,init_val,segfunc,ide_ele):
    n=len(init_val)
    self.segfunc=segfunc
    self.ide_ele=ide_ele
    self.num=1<<(n-1).bit_length()
    self.tree=[ide_ele]*2*self.num
    for i in range(n):
      self.tree[self.num+i]=init_val[i]
    for i in range(self.num-1,0,-1):
      self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1])
  def update(self,k,x):
    k+=self.num
    self.tree[k]=x
    while k>1:
      self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1])
      k>>=1
  def query(self,l,r):
    res=self.ide_ele
    l+=self.num
    r+=self.num
    while l<r:
      if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
      if r&1:
        res=self.segfunc(res,self.tree[r-1])
      l>>=1
      r>>=1
    return res SegTree q,c,r=input().split() input().split() q
def segfunc(x,y):
  return set(x)|set(y)
ide_ele=set()
class SegTree():
  def __init__(self,init_val,segfunc,ide_ele):
    n=len(init_val)
    self.segfunc=segfunc
    self.ide_ele=ide_ele
    self.num=1<<(n-1).bit_length()
    self.tree=[ide_ele]*2*self.num
    for i in range(n):
      self.tree[self.num+i]=init_val[i]
    for i in range(self.num-1,0,-1):
      self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1])
  def update(self,k,x):
    k+=self.num
    self.tree[k]=x
    while k>1:
      self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1])
      k>>=1
  def query(self,l,r):
    res=self.ide_ele
    l+=self.num
    r+=self.num
    while l<r:
      if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
      if r&1:
        res=self.segfunc(res,self.tree[r-1])
      l>>=1
      r>>=1
    return res
n=int(input())
s=input()
q=int(input())
st=SegTree(s,segfunc,ide_ele)
for _ in range(q):
  q,c,r=input().split()
  if q=='1':st.update(int(c)-1,r)
  else:print(len(st.query(int(c)-1,int(r))))