class SegmentTree:
    def __init__(self,orig,func,unit):
        _len= len(orig)
        self.func = func
        self.size = 1 << (_len-1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] *(self.size-_len)
        self.unit = unit
        
        for i in range(self.size -1,0,-1):
            self.tree[i] = func(self.tree[i*2], self.tree[i*2+1])
            
    def update(self, i, v):
        i+=self.size
        self.tree[i] = v
        while i:
            i//=2
            self.tree[i]=self.func(self.tree[i*2],self.tree[i*2+1])
    
    def find(self,l,r):
        l+=self.size
        r+=self.size
        ret=self.unit
        while l<r:
            if l&1:
                ret = self.func(ret,self.tree[l])
                l+=1
            if r&1:
                r-=1
                ret=self.func(ret,self.tree[r])
            l//=2
            r//=2
        return ret
      
import sys
input = sys.stdin.readline
from operator import or_

input()
seg = SegmentTree([1 << ord(x) - 97 for x in input()[:-1]], or_, 0)
ans = []
for _ in range(int(input())):
  f, x, y = input().split()
  if f == "1":
    seg.update(int(x) - 1, 1 << ord(y) - 97)
  else:
    ans.append(bin(seg.find(int(x) - 1, int(y))).count("1"))
print(*ans) class SegmentTree:
    def __init__(self,orig,func,unit):
        _len= len(orig)
        self.func = func
        self.size = 1 << (_len-1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] *(self.size-_len)
        self.unit = unit
        
        for i in range(self.size -1,0,-1):
            self.tree[i] = func(self.tree[i*2], self.tree[i*2+1])
            
    def update(self, i, v):
        i+=self.size
        self.tree[i] = v
        while i:
            i//=2
            self.tree[i]=self.func(self.tree[i*2],self.tree[i*2+1])
    
    def find(self,l,r):
        l+=self.size
        r+=self.size
        ret=self.unit
        while l<r:
            if l&1:
                ret = self.func(ret,self.tree[l])
                l+=1
            if r&1:
                r-=1
                ret=self.func(ret,self.tree[r])
            l//=2
            r//=2
        return ret
       SegmentTree def __init__(self,orig,func,unit):
        _len= len(orig)
        self.func = func
        self.size = 1 << (_len-1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] *(self.size-_len)
        self.unit = unit
        
        for i in range(self.size -1,0,-1):
            self.tree[i] = func(self.tree[i*2], self.tree[i*2+1])
            
     __init__ _len= len(orig) _len len(orig) len orig self.func = func self.func self func func self.size = 1 << (_len-1).bit_length() self.size self size 1 << (_len-1).bit_length() 1 (_len-1).bit_length() _len-1).bit_length _len-1 _len 1 bit_length self.tree = [unit] * self.size + orig + [unit] *(self.size-_len) self.tree self tree [unit] * self.size + orig + [unit] *(self.size-_len) [unit] * self.size + orig [unit] * self.size [unit] unit self.size self size orig [unit] *(self.size-_len) [unit] unit self.size-_len self.size self size _len self.unit = unit self.unit self unit unit for i in range(self.size -1,0,-1):
            self.tree[i] = func(self.tree[i*2], self.tree[i*2+1])
            
     i range(self.size -1,0,-1) range self.size -1 self.size self size 1 0 -1 self.tree[i] = func(self.tree[i*2], self.tree[i*2+1]) self.tree[i] self.tree self tree i func(self.tree[i*2], self.tree[i*2+1]) func self.tree[i*2] self.tree self tree i*2 i 2 self.tree[i*2+1] self.tree self tree i*2+1 i*2 i 2 1 self self orig orig func func unit unit def update(self, i, v):
        i+=self.size
        self.tree[i] = v
        while i:
            i//=2
            self.tree[i]=self.func(self.tree[i*2],self.tree[i*2+1])
    
     update i+=self.size i self.size self size self.tree[i] = v self.tree[i] self.tree self tree i v while i:
            i//=2
            self.tree[i]=self.func(self.tree[i*2],self.tree[i*2+1])
    
     i i//=2 i 2 self.tree[i]=self.func(self.tree[i*2],self.tree[i*2+1]) self.tree[i] self.tree self tree i self.func(self.tree[i*2],self.tree[i*2+1]) self.func self func self.tree[i*2] self.tree self tree i*2 i 2 self.tree[i*2+1] self.tree self tree i*2+1 i*2 i 2 1 self self i i v v def find(self,l,r):
        l+=self.size
        r+=self.size
        ret=self.unit
        while l<r:
            if l&1:
                ret = self.func(ret,self.tree[l])
                l+=1
            if r&1:
                r-=1
                ret=self.func(ret,self.tree[r])
            l//=2
            r//=2
        return ret
       find l+=self.size l self.size self size r+=self.size r self.size self size ret=self.unit ret self.unit self unit while l<r:
            if l&1:
                ret = self.func(ret,self.tree[l])
                l+=1
            if r&1:
                r-=1
                ret=self.func(ret,self.tree[r])
            l//=2
            r//=2
         l<r l r if l&1:
                ret = self.func(ret,self.tree[l])
                l+=1
             l&1 l 1 ret = self.func(ret,self.tree[l]) ret self.func(ret,self.tree[l]) self.func self func ret self.tree[l] self.tree self tree l l+=1 l 1 if r&1:
                r-=1
                ret=self.func(ret,self.tree[r])
             r&1 r 1 r-=1 r 1 ret=self.func(ret,self.tree[r]) ret self.func(ret,self.tree[r]) self.func self func ret self.tree[r] self.tree self tree r l//=2 l 2 r//=2 r 2 return ret ret self self l l r r import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline from operator import or_ input() input 1 << ord(x) - 97 for x in input()[:-1] for x in input()[:-1] x input()[:-1] () input :-1 -1 for x in input()[:-1] 1 << ord(x) - 97 1 ord(x) - 97 ord(x) ord x 97 seg = SegmentTree([1 << ord(x) - 97 for x in input()[:-1]], or_, 0) seg SegmentTree([1 << ord(x) - 97 for x in input()[:-1]], or_, 0) SegmentTree [1 << ord(x) - 97 for x in input()[:-1]] or_ 0 ans = [] ans [] for _ in range(int(input())):
  f, x, y = input().split()
  if f == "1":
    seg.update(int(x) - 1, 1 << ord(y) - 97)
  else:
    ans.append(bin(seg.find(int(x) - 1, int(y))).count("1")) _ range(int(input())) range int(input()) int input() input f, x, y = input().split() f input().split() ().split () input split x y if f == "1":
    seg.update(int(x) - 1, 1 << ord(y) - 97)
  else:
    ans.append(bin(seg.find(int(x) - 1, int(y))).count("1")) f == "1" f "1" seg.update(int(x) - 1, 1 << ord(y) - 97) seg.update seg update int(x) - 1 int(x) int x 1 1 << ord(y) - 97 1 ord(y) - 97 ord(y) ord y 97 ans.append(bin(seg.find(int(x) - 1, int(y))).count("1")) ans.append ans append bin(seg.find(int(x) - 1, int(y))).count("1") (seg.find(int(x) - 1, int(y))).count (seg.find(int(x) - 1, int(y))) bin seg.find(int(x) - 1, int(y)) seg.find seg find int(x) - 1 int(x) int x 1 int(y) int y count "1" print(*ans) print *ans ans class SegmentTree:
    def __init__(self,orig,func,unit):
        _len= len(orig)
        self.func = func
        self.size = 1 << (_len-1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] *(self.size-_len)
        self.unit = unit
        
        for i in range(self.size -1,0,-1):
            self.tree[i] = func(self.tree[i*2], self.tree[i*2+1])
            
    def update(self, i, v):
        i+=self.size
        self.tree[i] = v
        while i:
            i//=2
            self.tree[i]=self.func(self.tree[i*2],self.tree[i*2+1])
    
    def find(self,l,r):
        l+=self.size
        r+=self.size
        ret=self.unit
        while l<r:
            if l&1:
                ret = self.func(ret,self.tree[l])
                l+=1
            if r&1:
                r-=1
                ret=self.func(ret,self.tree[r])
            l//=2
            r//=2
        return ret
       class SegmentTree:
    def __init__(self,orig,func,unit):
        _len= len(orig)
        self.func = func
        self.size = 1 << (_len-1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] *(self.size-_len)
        self.unit = unit
        
        for i in range(self.size -1,0,-1):
            self.tree[i] = func(self.tree[i*2], self.tree[i*2+1])
            
    def update(self, i, v):
        i+=self.size
        self.tree[i] = v
        while i:
            i//=2
            self.tree[i]=self.func(self.tree[i*2],self.tree[i*2+1])
    
    def find(self,l,r):
        l+=self.size
        r+=self.size
        ret=self.unit
        while l<r:
            if l&1:
                ret = self.func(ret,self.tree[l])
                l+=1
            if r&1:
                r-=1
                ret=self.func(ret,self.tree[r])
            l//=2
            r//=2
        return ret
       SegmentTree input = sys.stdin.readline sys.stdin.readline input seg = SegmentTree([1 << ord(x) - 97 for x in input()[:-1]], or_, 0) SegmentTree([1 << ord(x) - 97 for x in input()[:-1]], or_, 0) seg ans = [] [] ans f, x, y = input().split() input().split() f x, y = input().split() input().split() x y = input().split() input().split() y
class SegmentTree:
    def __init__(self,orig,func,unit):
        _len= len(orig)
        self.func = func
        self.size = 1 << (_len-1).bit_length()
        self.tree = [unit] * self.size + orig + [unit] *(self.size-_len)
        self.unit = unit
        
        for i in range(self.size -1,0,-1):
            self.tree[i] = func(self.tree[i*2], self.tree[i*2+1])
            
    def update(self, i, v):
        i+=self.size
        self.tree[i] = v
        while i:
            i//=2
            self.tree[i]=self.func(self.tree[i*2],self.tree[i*2+1])
    
    def find(self,l,r):
        l+=self.size
        r+=self.size
        ret=self.unit
        while l<r:
            if l&1:
                ret = self.func(ret,self.tree[l])
                l+=1
            if r&1:
                r-=1
                ret=self.func(ret,self.tree[r])
            l//=2
            r//=2
        return ret
      
import sys
input = sys.stdin.readline
from operator import or_

input()
seg = SegmentTree([1 << ord(x) - 97 for x in input()[:-1]], or_, 0)
ans = []
for _ in range(int(input())):
  f, x, y = input().split()
  if f == "1":
    seg.update(int(x) - 1, 1 << ord(y) - 97)
  else:
    ans.append(bin(seg.find(int(x) - 1, int(y))).count("1"))
print(*ans)