import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

class segtree():#seg=segtree(A),単位元とsegfuncを指定すること
    def __init__(self,A,ide=0):#単位元とsegfuncを指定すること
        n=len(A)
        num=2**(n-1).bit_length()#n以上の最小の2のべき乗
        seg=[ide]*(2*num-1)
        segfunc=self.segfunc
        self.ide,self.n,self.num,self.seg = ide, n, num, seg
        for i in range(n): seg[i+num-1]=A[i]#setvalue
        for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])#build
    
    def segfunc(self,x,y):return x|y #seg木の基本関数
    
    def update(self,k,x):#Aのk番目の要素をxに置き換える,計算量log(N)
        k += self.num-1
        seg,segfunc=self.seg,self.segfunc
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
    def query(self,p,q):#区間[p,q)の累積segfuncを求める,計算量log(N)
        if q<=p: return self.ide
        num,segfunc,seg=self.num,self.segfunc,self.seg
        p += num-1; q += num-2
        res=self.ide
        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,q = p//2, (q-1)//2
        if p == q: res = segfunc(res,seg[p])
        else: res = segfunc(segfunc(res,seg[p]),seg[q])
        return res 

def main():
    mod = 10**9+7
    alpha2num = lambda c: 2**(ord(c) - ord('a'))
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    S=input()
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    A=list(map(alpha2num, list(S)))
    #print(A)
    #exit()
    seg=segtree(A)
    #print(A)
    Q=int(input())
    for i in range(Q):
        t, a,b =input().split()
        if t=='1':
            a=int(a)
            seg.update(a-1,alpha2num(b))
        else:
            a,b=int(a),int(b)
            x=seg.query(a-1,b)
            count=0
            for i in range(26):
                count+= (x>>i & 1)
            print(count)






if __name__ == "__main__":
    main() import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 import math math from copy import copy, deepcopy from operator import itemgetter from bisect import bisect_left, bisect, bisect_right from collections import deque from collections import Counter from itertools import accumulate from heapq import heapify,heappop,heappush def input(): return sys.stdin.readline()[:-1] input def printl(li): print(*li, sep="\n") printl li li def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds argsort inds=sorted(range(len(s)), key=lambda k: s[k]) inds sorted(range(len(s)), key=lambda k: s[k]) sorted range(len(s)) range len(s) len s key=lambda k: s[k] key lambda k: s[k] s[k] s k k s[i] for i in inds for i in inds i inds for i in inds s[i] s i if return_sorted: return inds, [s[i] for i in inds]
     return_sorted return inds inds s s return_sorted=False return_sorted False class segtree():#seg=segtree(A),単位元とsegfuncを指定すること
    def __init__(self,A,ide=0):#単位元とsegfuncを指定すること
        n=len(A)
        num=2**(n-1).bit_length()#n以上の最小の2のべき乗
        seg=[ide]*(2*num-1)
        segfunc=self.segfunc
        self.ide,self.n,self.num,self.seg = ide, n, num, seg
        for i in range(n): seg[i+num-1]=A[i]#setvalue
        for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])#build
    
    def segfunc(self,x,y):return x|y #seg木の基本関数
    
    def update(self,k,x):#Aのk番目の要素をxに置き換える,計算量log(N)
        k += self.num-1
        seg,segfunc=self.seg,self.segfunc
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
    def query(self,p,q):#区間[p,q)の累積segfuncを求める,計算量log(N)
        if q<=p: return self.ide
        num,segfunc,seg=self.num,self.segfunc,self.seg
        p += num-1; q += num-2
        res=self.ide
        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,q = p//2, (q-1)//2
        if p == q: res = segfunc(res,seg[p])
        else: res = segfunc(segfunc(res,seg[p]),seg[q])
        return res  segtree def __init__(self,A,ide=0):#単位元とsegfuncを指定すること
        n=len(A)
        num=2**(n-1).bit_length()#n以上の最小の2のべき乗
        seg=[ide]*(2*num-1)
        segfunc=self.segfunc
        self.ide,self.n,self.num,self.seg = ide, n, num, seg
        for i in range(n): seg[i+num-1]=A[i]#setvalue
        for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])#build
    
     __init__ n=len(A) n len(A) len A 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]*(2*num-1) seg [ide]*(2*num-1) [ide] ide 2*num-1 2*num 2 num 1 segfunc=self.segfunc segfunc self.segfunc self segfunc self.ide,self.n,self.num,self.seg = ide, n, num, seg self.ide self ide ide self.n self n n self.num self num num self.seg self seg seg for i in range(n): seg[i+num-1]=A[i]#setvalue
         i range(n) range n for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])#build
    
     i range(num-2,-1,-1) range num-2 num 2 -1 -1 self self A A ide=0 ide 0 def segfunc(self,x,y):return x|y #seg木の基本関数
    
     segfunc self self x x y y def update(self,k,x):#Aのk番目の要素をxに置き換える,計算量log(N)
        k += self.num-1
        seg,segfunc=self.seg,self.segfunc
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
     update k += self.num-1 k self.num-1 self.num self num 1 seg,segfunc=self.seg,self.segfunc seg self.seg self seg segfunc self.segfunc self segfunc 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 self self k k x x def query(self,p,q):#区間[p,q)の累積segfuncを求める,計算量log(N)
        if q<=p: return self.ide
        num,segfunc,seg=self.num,self.segfunc,self.seg
        p += num-1; q += num-2
        res=self.ide
        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,q = p//2, (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 self.ide
         q<=p q p num,segfunc,seg=self.num,self.segfunc,self.seg num self.num self num segfunc self.segfunc self segfunc seg self.seg self seg p += num-1 p num-1 num 1 q += num-2 q num-2 num 2 res=self.ide res self.ide self ide 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,q = p//2, (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 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,q = p//2, (q-1)//2 p p//2 p 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 return res res self self p p q q def main():
    mod = 10**9+7
    alpha2num = lambda c: 2**(ord(c) - ord('a'))
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    S=input()
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    A=list(map(alpha2num, list(S)))
    #print(A)
    #exit()
    seg=segtree(A)
    #print(A)
    Q=int(input())
    for i in range(Q):
        t, a,b =input().split()
        if t=='1':
            a=int(a)
            seg.update(a-1,alpha2num(b))
        else:
            a,b=int(a),int(b)
            x=seg.query(a-1,b)
            count=0
            for i in range(26):
                count+= (x>>i & 1)
            print(count) main mod = 10**9+7 mod 10**9+7 10**9 10 9 7 alpha2num = lambda c: 2**(ord(c) - ord('a')) alpha2num lambda c: 2**(ord(c) - ord('a')) 2**(ord(c) - ord('a')) 2 ord(c) - ord('a') ord(c) ord c ord('a') ord 'a' c N = int(input()) N int(input()) int input() input S=input() S input() input A=list(map(alpha2num, list(S))) A list(map(alpha2num, list(S))) list map(alpha2num, list(S)) map alpha2num list(S) list S seg=segtree(A) seg segtree(A) segtree A Q=int(input()) Q int(input()) int input() input for i in range(Q):
        t, a,b =input().split()
        if t=='1':
            a=int(a)
            seg.update(a-1,alpha2num(b))
        else:
            a,b=int(a),int(b)
            x=seg.query(a-1,b)
            count=0
            for i in range(26):
                count+= (x>>i & 1)
            print(count) i range(Q) range Q t, a,b =input().split() t input().split() ().split () input split a b if t=='1':
            a=int(a)
            seg.update(a-1,alpha2num(b))
        else:
            a,b=int(a),int(b)
            x=seg.query(a-1,b)
            count=0
            for i in range(26):
                count+= (x>>i & 1)
            print(count) t=='1' t '1' a=int(a) a int(a) int a seg.update(a-1,alpha2num(b)) seg.update seg update a-1 a 1 alpha2num(b) alpha2num b a,b=int(a),int(b) a int(a) int a b int(b) int b x=seg.query(a-1,b) x seg.query(a-1,b) seg.query seg query a-1 a 1 b count=0 count 0 for i in range(26):
                count+= (x>>i & 1)
             i range(26) range 26 count+= (x>>i & 1) count x>>i & 1 x>>i x i 1 print(count) print count if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def input(): return sys.stdin.readline()[:-1] def input(): return sys.stdin.readline()[:-1] input def printl(li): print(*li, sep="\n") def printl(li): print(*li, sep="\n") printl def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds argsort class segtree():#seg=segtree(A),単位元とsegfuncを指定すること
    def __init__(self,A,ide=0):#単位元とsegfuncを指定すること
        n=len(A)
        num=2**(n-1).bit_length()#n以上の最小の2のべき乗
        seg=[ide]*(2*num-1)
        segfunc=self.segfunc
        self.ide,self.n,self.num,self.seg = ide, n, num, seg
        for i in range(n): seg[i+num-1]=A[i]#setvalue
        for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])#build
    
    def segfunc(self,x,y):return x|y #seg木の基本関数
    
    def update(self,k,x):#Aのk番目の要素をxに置き換える,計算量log(N)
        k += self.num-1
        seg,segfunc=self.seg,self.segfunc
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
    def query(self,p,q):#区間[p,q)の累積segfuncを求める,計算量log(N)
        if q<=p: return self.ide
        num,segfunc,seg=self.num,self.segfunc,self.seg
        p += num-1; q += num-2
        res=self.ide
        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,q = p//2, (q-1)//2
        if p == q: res = segfunc(res,seg[p])
        else: res = segfunc(segfunc(res,seg[p]),seg[q])
        return res  class segtree():#seg=segtree(A),単位元とsegfuncを指定すること
    def __init__(self,A,ide=0):#単位元とsegfuncを指定すること
        n=len(A)
        num=2**(n-1).bit_length()#n以上の最小の2のべき乗
        seg=[ide]*(2*num-1)
        segfunc=self.segfunc
        self.ide,self.n,self.num,self.seg = ide, n, num, seg
        for i in range(n): seg[i+num-1]=A[i]#setvalue
        for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])#build
    
    def segfunc(self,x,y):return x|y #seg木の基本関数
    
    def update(self,k,x):#Aのk番目の要素をxに置き換える,計算量log(N)
        k += self.num-1
        seg,segfunc=self.seg,self.segfunc
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
    def query(self,p,q):#区間[p,q)の累積segfuncを求める,計算量log(N)
        if q<=p: return self.ide
        num,segfunc,seg=self.num,self.segfunc,self.seg
        p += num-1; q += num-2
        res=self.ide
        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,q = p//2, (q-1)//2
        if p == q: res = segfunc(res,seg[p])
        else: res = segfunc(segfunc(res,seg[p]),seg[q])
        return res  segtree def main():
    mod = 10**9+7
    alpha2num = lambda c: 2**(ord(c) - ord('a'))
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    S=input()
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    A=list(map(alpha2num, list(S)))
    #print(A)
    #exit()
    seg=segtree(A)
    #print(A)
    Q=int(input())
    for i in range(Q):
        t, a,b =input().split()
        if t=='1':
            a=int(a)
            seg.update(a-1,alpha2num(b))
        else:
            a,b=int(a),int(b)
            x=seg.query(a-1,b)
            count=0
            for i in range(26):
                count+= (x>>i & 1)
            print(count) def main():
    mod = 10**9+7
    alpha2num = lambda c: 2**(ord(c) - ord('a'))
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    S=input()
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    A=list(map(alpha2num, list(S)))
    #print(A)
    #exit()
    seg=segtree(A)
    #print(A)
    Q=int(input())
    for i in range(Q):
        t, a,b =input().split()
        if t=='1':
            a=int(a)
            seg.update(a-1,alpha2num(b))
        else:
            a,b=int(a),int(b)
            x=seg.query(a-1,b)
            count=0
            for i in range(26):
                count+= (x>>i & 1)
            print(count) main
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

class segtree():#seg=segtree(A),単位元とsegfuncを指定すること
    def __init__(self,A,ide=0):#単位元とsegfuncを指定すること
        n=len(A)
        num=2**(n-1).bit_length()#n以上の最小の2のべき乗
        seg=[ide]*(2*num-1)
        segfunc=self.segfunc
        self.ide,self.n,self.num,self.seg = ide, n, num, seg
        for i in range(n): seg[i+num-1]=A[i]#setvalue
        for i in range(num-2,-1,-1):seg[i]=segfunc(seg[2*i+1],seg[2*i+2])#build
    
    def segfunc(self,x,y):return x|y #seg木の基本関数
    
    def update(self,k,x):#Aのk番目の要素をxに置き換える,計算量log(N)
        k += self.num-1
        seg,segfunc=self.seg,self.segfunc
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
    def query(self,p,q):#区間[p,q)の累積segfuncを求める,計算量log(N)
        if q<=p: return self.ide
        num,segfunc,seg=self.num,self.segfunc,self.seg
        p += num-1; q += num-2
        res=self.ide
        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,q = p//2, (q-1)//2
        if p == q: res = segfunc(res,seg[p])
        else: res = segfunc(segfunc(res,seg[p]),seg[q])
        return res 

def main():
    mod = 10**9+7
    alpha2num = lambda c: 2**(ord(c) - ord('a'))
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    S=input()
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    A=list(map(alpha2num, list(S)))
    #print(A)
    #exit()
    seg=segtree(A)
    #print(A)
    Q=int(input())
    for i in range(Q):
        t, a,b =input().split()
        if t=='1':
            a=int(a)
            seg.update(a-1,alpha2num(b))
        else:
            a,b=int(a),int(b)
            x=seg.query(a-1,b)
            count=0
            for i in range(26):
                count+= (x>>i & 1)
            print(count)






if __name__ == "__main__":
    main()