#####segfunc######
def segfunc(x,y):
  return x|y 

def init(init_val):
  #set_val
  for i in range(n):
    seg[i+num-1]=init_val[i]  
  #built
  for i in range(num-2,-1,-1) :
    seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
  
def update(k,x):
  k += num-1
  seg[k] = x
  while k:
    k = (k-1)//2
    seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
  
def query(p,q):
  if q<=p:
    return ide_ele
  p += num-1
  q += num-2
  res=ide_ele
  while q-p>1:
    if p&1 == 0:
      res = segfunc(res,seg[p])
    if q&1 == 1:
      res = segfunc(res,seg[q])
      q -= 1
    p = p//2
    q = (q-1)//2
  if p == q:
    res = segfunc(res,seg[p])
  else:
    res = segfunc(segfunc(res,seg[p]),seg[q])
  return res

#####単位元######
ide_ele = set([])

#num:n以上の最小の2のべき乗
n = int(input())
S = [set([s]) for s in input()]
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

init(S)
q = int(input())
for _ in range(q):
  a,b,c = input().split()
  if a == '1':
    b = int(b)-1
    update(b, set([c]))
  elif a == '2':
    b = int(b)-1
    c = int(c)
    print(len(query(b,c))) def segfunc(x,y):
  return x|y  segfunc return x|y x|y x y x x y y def init(init_val):
  #set_val
  for i in range(n):
    seg[i+num-1]=init_val[i]  
  #built
  for i in range(num-2,-1,-1) :
    seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
   init for i in range(n):
    seg[i+num-1]=init_val[i]  
  #built
   i range(n) range n seg[i+num-1]=init_val[i] seg[i+num-1] seg i+num-1 i+num i num 1 init_val[i] init_val i 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 seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) seg[i] seg i segfunc(seg[2*i+1],seg[2*i+2]) segfunc seg[2*i+1] seg 2*i+1 2*i 2 i 1 seg[2*i+2] seg 2*i+2 2*i 2 i 2 init_val init_val def update(k,x):
  k += num-1
  seg[k] = x
  while k:
    k = (k-1)//2
    seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
   update k += num-1 k num-1 num 1 seg[k] = x seg[k] seg k x while k:
    k = (k-1)//2
    seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
   k k = (k-1)//2 k (k-1)//2 k-1 k 1 2 seg[k] = segfunc(seg[k*2+1],seg[k*2+2]) seg[k] seg k segfunc(seg[k*2+1],seg[k*2+2]) segfunc seg[k*2+1] seg k*2+1 k*2 k 2 1 seg[k*2+2] seg k*2+2 k*2 k 2 2 k k x x def query(p,q):
  if q<=p:
    return ide_ele
  p += num-1
  q += num-2
  res=ide_ele
  while q-p>1:
    if p&1 == 0:
      res = segfunc(res,seg[p])
    if q&1 == 1:
      res = segfunc(res,seg[q])
      q -= 1
    p = p//2
    q = (q-1)//2
  if p == q:
    res = segfunc(res,seg[p])
  else:
    res = segfunc(segfunc(res,seg[p]),seg[q])
  return res

#####単位元###### query if q<=p:
    return ide_ele
   q<=p q p return ide_ele ide_ele p += num-1 p num-1 num 1 q += num-2 q num-2 num 2 res=ide_ele res ide_ele while q-p>1:
    if p&1 == 0:
      res = segfunc(res,seg[p])
    if q&1 == 1:
      res = segfunc(res,seg[q])
      q -= 1
    p = p//2
    q = (q-1)//2
   q-p>1 q-p q p 1 if p&1 == 0:
      res = segfunc(res,seg[p])
     p&1 == 0 p&1 p 1 0 res = segfunc(res,seg[p]) res segfunc(res,seg[p]) segfunc res seg[p] seg p if q&1 == 1:
      res = segfunc(res,seg[q])
      q -= 1
     q&1 == 1 q&1 q 1 1 res = segfunc(res,seg[q]) res segfunc(res,seg[q]) segfunc res seg[q] seg q q -= 1 q 1 p = p//2 p p//2 p 2 q = (q-1)//2 q (q-1)//2 q-1 q 1 2 if p == q:
    res = segfunc(res,seg[p])
  else:
    res = segfunc(segfunc(res,seg[p]),seg[q])
   p == q p q res = segfunc(res,seg[p]) res segfunc(res,seg[p]) segfunc res seg[p] seg p res = segfunc(segfunc(res,seg[p]),seg[q]) res segfunc(segfunc(res,seg[p]),seg[q]) segfunc segfunc(res,seg[p]) segfunc res seg[p] seg p seg[q] seg q return res res p p q q ide_ele = set([]) ide_ele set([]) set [] n = int(input()) n int(input()) int input() input set([s]) for s in input() for s in input() s input() input for s in input() set([s]) set [s] s S = [set([s]) for s in input()] S [set([s]) for s in 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 seg=[ide_ele]*2*num seg [ide_ele]*2*num [ide_ele]*2 [ide_ele] ide_ele 2 num init(S) init S q = int(input()) q int(input()) int input() input for _ in range(q):
  a,b,c = input().split()
  if a == '1':
    b = int(b)-1
    update(b, set([c]))
  elif a == '2':
    b = int(b)-1
    c = int(c)
    print(len(query(b,c))) _ range(q) range q a,b,c = input().split() a input().split() ().split () input split b c if a == '1':
    b = int(b)-1
    update(b, set([c]))
  elif a == '2':
    b = int(b)-1
    c = int(c)
    print(len(query(b,c))) a == '1' a '1' b = int(b)-1 b int(b)-1 int(b) int b 1 update(b, set([c])) update b set([c]) set [c] c elif a == '2':
    b = int(b)-1
    c = int(c)
    print(len(query(b,c))) a == '2' a '2' b = int(b)-1 b int(b)-1 int(b) int b 1 c = int(c) c int(c) int c print(len(query(b,c))) print len(query(b,c)) len query(b,c) query b c b = int(b)-1 int(b)-1 b ide_ele = set([]) set([]) ide_ele q = int(input()) int(input()) q def update(k,x):
  k += num-1
  seg[k] = x
  while k:
    k = (k-1)//2
    seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
   def update(k,x):
  k += num-1
  seg[k] = x
  while k:
    k = (k-1)//2
    seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
   update S = [set([s]) for s in input()] [set([s]) for s in input()] S b,c = input().split() input().split() b c = input().split() input().split() c def query(p,q):
  if q<=p:
    return ide_ele
  p += num-1
  q += num-2
  res=ide_ele
  while q-p>1:
    if p&1 == 0:
      res = segfunc(res,seg[p])
    if q&1 == 1:
      res = segfunc(res,seg[q])
      q -= 1
    p = p//2
    q = (q-1)//2
  if p == q:
    res = segfunc(res,seg[p])
  else:
    res = segfunc(segfunc(res,seg[p]),seg[q])
  return res

#####単位元###### def query(p,q):
  if q<=p:
    return ide_ele
  p += num-1
  q += num-2
  res=ide_ele
  while q-p>1:
    if p&1 == 0:
      res = segfunc(res,seg[p])
    if q&1 == 1:
      res = segfunc(res,seg[q])
      q -= 1
    p = p//2
    q = (q-1)//2
  if p == q:
    res = segfunc(res,seg[p])
  else:
    res = segfunc(segfunc(res,seg[p]),seg[q])
  return res

#####単位元###### query c = int(c) int(c) c b = int(b)-1 int(b)-1 b n = int(input()) int(input()) n num =2**(n-1).bit_length() 2**(n-1).bit_length() num seg=[ide_ele]*2*num [ide_ele]*2*num seg def segfunc(x,y):
  return x|y  def segfunc(x,y):
  return x|y  segfunc def init(init_val):
  #set_val
  for i in range(n):
    seg[i+num-1]=init_val[i]  
  #built
  for i in range(num-2,-1,-1) :
    seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
   def init(init_val):
  #set_val
  for i in range(n):
    seg[i+num-1]=init_val[i]  
  #built
  for i in range(num-2,-1,-1) :
    seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
   init a,b,c = input().split() input().split() a
#####segfunc######
def segfunc(x,y):
  return x|y 

def init(init_val):
  #set_val
  for i in range(n):
    seg[i+num-1]=init_val[i]  
  #built
  for i in range(num-2,-1,-1) :
    seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
  
def update(k,x):
  k += num-1
  seg[k] = x
  while k:
    k = (k-1)//2
    seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
  
def query(p,q):
  if q<=p:
    return ide_ele
  p += num-1
  q += num-2
  res=ide_ele
  while q-p>1:
    if p&1 == 0:
      res = segfunc(res,seg[p])
    if q&1 == 1:
      res = segfunc(res,seg[q])
      q -= 1
    p = p//2
    q = (q-1)//2
  if p == q:
    res = segfunc(res,seg[p])
  else:
    res = segfunc(segfunc(res,seg[p]),seg[q])
  return res

#####単位元######
ide_ele = set([])

#num:n以上の最小の2のべき乗
n = int(input())
S = [set([s]) for s in input()]
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num

init(S)
q = int(input())
for _ in range(q):
  a,b,c = input().split()
  if a == '1':
    b = int(b)-1
    update(b, set([c]))
  elif a == '2':
    b = int(b)-1
    c = int(c)
    print(len(query(b,c)))