class SegTree:
    def __init__(self, init_val, ide_ele, segfunc):
        self.n = len(init_val)
        self.num =2**(self.n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg = [self.ide_ele]*2*self.num
        self.segfunc = segfunc
        
        #set_val
        for i in range(self.n):
            self.seg[i+self.num-1] = init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i] = segfunc(self.seg[2*i+1], self.seg[2*i+2]) 
    
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res
    
import sys
input = sys.stdin.readline
N = int(input())
S = input()
L = [-1]*N
for i in range(N):
    L[i] = 2**(ord(S[i]) - ord('a'))
    
def segfunc(a,b):
    return a | b

Seg = SegTree(L,0,segfunc)

Q = int(input())

for _ in range(Q):
    q,a,b = input().split()
    if q == '1':
        i = int(a)-1
        c = 2**(ord(b) - ord('a'))
        Seg.update(i,c)
    elif q=='2':
        l = int(a)-1
        r = int(b)-1
        X = Seg.query(l,r+1)
        tmp = 0
        for j in range(30):
            if X%2==1:
                tmp += 1
            X//=2
        print(tmp) class SegTree:
    def __init__(self, init_val, ide_ele, segfunc):
        self.n = len(init_val)
        self.num =2**(self.n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg = [self.ide_ele]*2*self.num
        self.segfunc = segfunc
        
        #set_val
        for i in range(self.n):
            self.seg[i+self.num-1] = init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i] = segfunc(self.seg[2*i+1], self.seg[2*i+2]) 
    
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res
     SegTree def __init__(self, init_val, ide_ele, segfunc):
        self.n = len(init_val)
        self.num =2**(self.n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg = [self.ide_ele]*2*self.num
        self.segfunc = segfunc
        
        #set_val
        for i in range(self.n):
            self.seg[i+self.num-1] = init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i] = segfunc(self.seg[2*i+1], self.seg[2*i+2]) 
    
     __init__ self.n = len(init_val) self.n self n len(init_val) len init_val self.num =2**(self.n-1).bit_length() self.num self num 2**(self.n-1).bit_length() 2 (self.n-1).bit_length() self.n-1).bit_length self.n-1 self.n self n 1 bit_length self.ide_ele = ide_ele self.ide_ele self ide_ele ide_ele self.seg = [self.ide_ele]*2*self.num self.seg self seg [self.ide_ele]*2*self.num [self.ide_ele]*2 [self.ide_ele] self.ide_ele self ide_ele 2 self.num self num self.segfunc = segfunc self.segfunc self segfunc segfunc for i in range(self.n):
            self.seg[i+self.num-1] = init_val[i]    
        #built
         i range(self.n) range self.n self n self.seg[i+self.num-1] = init_val[i] self.seg[i+self.num-1] self.seg self seg i+self.num-1 i+self.num i self.num self num 1 init_val[i] init_val i for i in range(self.num-2,-1,-1) :
            self.seg[i] = segfunc(self.seg[2*i+1], self.seg[2*i+2]) 
    
     i range(self.num-2,-1,-1) range self.num-2 self.num self num 2 -1 -1 self.seg[i] = segfunc(self.seg[2*i+1], self.seg[2*i+2]) self.seg[i] self.seg self seg i segfunc(self.seg[2*i+1], self.seg[2*i+2]) segfunc self.seg[2*i+1] self.seg self seg 2*i+1 2*i 2 i 1 self.seg[2*i+2] self.seg self seg 2*i+2 2*i 2 i 2 self self init_val init_val ide_ele ide_ele segfunc segfunc def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    
     update k += self.num-1 k self.num-1 self.num self num 1 self.seg[k] = x self.seg[k] self.seg self seg k x while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    
     k+1 k 1 k = (k-1)//2 k (k-1)//2 k-1 k 1 2 self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2]) self.seg[k] self.seg self seg k self.segfunc(self.seg[k*2+1], self.seg[k*2+2]) self.segfunc self segfunc self.seg[k*2+1] self.seg self seg k*2+1 k*2 k 2 1 self.seg[k*2+2] self.seg self seg k*2+2 k*2 k 2 2 self self k k x x def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res
     query if q<=p:
            return self.ide_ele
         q<=p q p return self.ide_ele self.ide_ele self ide_ele p += self.num-1 p self.num-1 self.num self num 1 q += self.num-2 q self.num-2 self.num self num 2 res = self.ide_ele res self.ide_ele self ide_ele while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
         q-p>1 q-p q p 1 if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
             p&1 == 0 p&1 p 1 0 res = self.segfunc(res, self.seg[p]) res self.segfunc(res, self.seg[p]) self.segfunc self segfunc res self.seg[p] self.seg self seg p if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
             q&1 == 1 q&1 q 1 1 res = self.segfunc(res, self.seg[q]) res self.segfunc(res, self.seg[q]) self.segfunc self segfunc res self.seg[q] self.seg self 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 = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
         p == q p q res = self.segfunc(res, self.seg[p]) res self.segfunc(res, self.seg[p]) self.segfunc self segfunc res self.seg[p] self.seg self seg p res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) res self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) self.segfunc self segfunc self.segfunc(res, self.seg[p]) self.segfunc self segfunc res self.seg[p] self.seg self seg p self.seg[q] self.seg self seg q return res res self self p p q q 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 L = [-1]*N L [-1]*N [-1] -1 N for i in range(N):
    L[i] = 2**(ord(S[i]) - ord('a'))
     i range(N) range N L[i] = 2**(ord(S[i]) - ord('a')) L[i] L i 2**(ord(S[i]) - ord('a')) 2 ord(S[i]) - ord('a') ord(S[i]) ord S[i] S i ord('a') ord 'a' def segfunc(a,b):
    return a | b segfunc return a | b a | b a b a a b b Seg = SegTree(L,0,segfunc) Seg SegTree(L,0,segfunc) SegTree L 0 segfunc Q = int(input()) Q int(input()) int input() input for _ in range(Q):
    q,a,b = input().split()
    if q == '1':
        i = int(a)-1
        c = 2**(ord(b) - ord('a'))
        Seg.update(i,c)
    elif q=='2':
        l = int(a)-1
        r = int(b)-1
        X = Seg.query(l,r+1)
        tmp = 0
        for j in range(30):
            if X%2==1:
                tmp += 1
            X//=2
        print(tmp) _ range(Q) range Q q,a,b = input().split() q input().split() ().split () input split a b if q == '1':
        i = int(a)-1
        c = 2**(ord(b) - ord('a'))
        Seg.update(i,c)
    elif q=='2':
        l = int(a)-1
        r = int(b)-1
        X = Seg.query(l,r+1)
        tmp = 0
        for j in range(30):
            if X%2==1:
                tmp += 1
            X//=2
        print(tmp) q == '1' q '1' i = int(a)-1 i int(a)-1 int(a) int a 1 c = 2**(ord(b) - ord('a')) c 2**(ord(b) - ord('a')) 2 ord(b) - ord('a') ord(b) ord b ord('a') ord 'a' Seg.update(i,c) Seg.update Seg update i c elif q=='2':
        l = int(a)-1
        r = int(b)-1
        X = Seg.query(l,r+1)
        tmp = 0
        for j in range(30):
            if X%2==1:
                tmp += 1
            X//=2
        print(tmp) q=='2' q '2' l = int(a)-1 l int(a)-1 int(a) int a 1 r = int(b)-1 r int(b)-1 int(b) int b 1 X = Seg.query(l,r+1) X Seg.query(l,r+1) Seg.query Seg query l r+1 r 1 tmp = 0 tmp 0 for j in range(30):
            if X%2==1:
                tmp += 1
            X//=2
         j range(30) range 30 if X%2==1:
                tmp += 1
             X%2==1 X%2 X 2 1 tmp += 1 tmp 1 X//=2 X 2 print(tmp) print tmp b = input().split() input().split() b input = sys.stdin.readline sys.stdin.readline input X//=2 2 X def segfunc(a,b):
    return a | b def segfunc(a,b):
    return a | b segfunc a,b = input().split() input().split() a c = 2**(ord(b) - ord('a')) 2**(ord(b) - ord('a')) c L = [-1]*N [-1]*N L tmp = 0 0 tmp i = int(a)-1 int(a)-1 i l = int(a)-1 int(a)-1 l S = input() input() S Q = int(input()) int(input()) Q tmp += 1 1 tmp class SegTree:
    def __init__(self, init_val, ide_ele, segfunc):
        self.n = len(init_val)
        self.num =2**(self.n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg = [self.ide_ele]*2*self.num
        self.segfunc = segfunc
        
        #set_val
        for i in range(self.n):
            self.seg[i+self.num-1] = init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i] = segfunc(self.seg[2*i+1], self.seg[2*i+2]) 
    
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res
     class SegTree:
    def __init__(self, init_val, ide_ele, segfunc):
        self.n = len(init_val)
        self.num =2**(self.n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg = [self.ide_ele]*2*self.num
        self.segfunc = segfunc
        
        #set_val
        for i in range(self.n):
            self.seg[i+self.num-1] = init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i] = segfunc(self.seg[2*i+1], self.seg[2*i+2]) 
    
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res
     SegTree N = int(input()) int(input()) N r = int(b)-1 int(b)-1 r Seg = SegTree(L,0,segfunc) SegTree(L,0,segfunc) Seg X = Seg.query(l,r+1) Seg.query(l,r+1) X q,a,b = input().split() input().split() q
class SegTree:
    def __init__(self, init_val, ide_ele, segfunc):
        self.n = len(init_val)
        self.num =2**(self.n-1).bit_length()
        self.ide_ele = ide_ele
        self.seg = [self.ide_ele]*2*self.num
        self.segfunc = segfunc
        
        #set_val
        for i in range(self.n):
            self.seg[i+self.num-1] = init_val[i]    
        #built
        for i in range(self.num-2,-1,-1) :
            self.seg[i] = segfunc(self.seg[2*i+1], self.seg[2*i+2]) 
    
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k+1:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    
    def query(self, p, q):
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res
    
import sys
input = sys.stdin.readline
N = int(input())
S = input()
L = [-1]*N
for i in range(N):
    L[i] = 2**(ord(S[i]) - ord('a'))
    
def segfunc(a,b):
    return a | b

Seg = SegTree(L,0,segfunc)

Q = int(input())

for _ in range(Q):
    q,a,b = input().split()
    if q == '1':
        i = int(a)-1
        c = 2**(ord(b) - ord('a'))
        Seg.update(i,c)
    elif q=='2':
        l = int(a)-1
        r = int(b)-1
        X = Seg.query(l,r+1)
        tmp = 0
        for j in range(30):
            if X%2==1:
                tmp += 1
            X//=2
        print(tmp)