import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))

# rstrip().decode('utf-8')

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

#####ide_ele#####
ide_ele = 1
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        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番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        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):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        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

def main():
	n=II()
	s=input().rstrip().decode()
	S=[]
	for i in s:
		S.append(ord(i)-ord("a"))
	
	seg=[SegTree([1]*n,segfunc,ide_ele) for _ in range(26)]
	
	#print(S)
	#print(seg)
	for i in range(n):
		seg[S[i]].update(i,0)
	
	q=II()
	for _ in range(q):
		a,b,c=input().split()
		if int(a)==1:
			b=int(b)-1
			seg[S[b]].update(b,1)
			t=ord(c)-ord("a")
			seg[t].update(b,0)
			S[b]=t
		
		else:
			#print(S)
			b=int(b)-1
			c=int(c)
			cnt=0
			for se in seg:
				if se.query(b,c)==0:
					cnt+=1
			print(cnt)
			
	
	

if __name__=="__main__":
	main() import sys sys input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline def RD(): return sys.stdin.read() RD def II(): return int(input()) II def MI(): return map(int,input().split()) MI def MF(): return map(float,input().split()) MF def LI(): return list(map(int,input().split())) LI def LF(): return list(map(float,input().split())) LF def TI(): return tuple(map(int,input().split()))

# rstrip().decode('utf-8')

#####segfunc##### TI def segfunc(x, y):
    return x*y
#################

#####ide_ele##### segfunc return x*y x*y x y x x y y ide_ele = 1 ide_ele 1 class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        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番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        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):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        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 """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """ def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        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__ """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """ 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番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        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番目の値をxに更新
        k: index(0-index)
        x: update value
        """ 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):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        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 """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """ 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 def main():
	n=II()
	s=input().rstrip().decode()
	S=[]
	for i in s:
		S.append(ord(i)-ord("a"))
	
	seg=[SegTree([1]*n,segfunc,ide_ele) for _ in range(26)]
	
	#print(S)
	#print(seg)
	for i in range(n):
		seg[S[i]].update(i,0)
	
	q=II()
	for _ in range(q):
		a,b,c=input().split()
		if int(a)==1:
			b=int(b)-1
			seg[S[b]].update(b,1)
			t=ord(c)-ord("a")
			seg[t].update(b,0)
			S[b]=t
		
		else:
			#print(S)
			b=int(b)-1
			c=int(c)
			cnt=0
			for se in seg:
				if se.query(b,c)==0:
					cnt+=1
			print(cnt)
			
	
	 main n=II() n II() II s=input().rstrip().decode() s input().rstrip().decode() ().rstrip().decode ().rstrip() ().rstrip () input rstrip decode S=[] S [] for i in s:
		S.append(ord(i)-ord("a"))
	
	 i s S.append(ord(i)-ord("a")) S.append S append ord(i)-ord("a") ord(i) ord i ord("a") ord "a" SegTree([1]*n,segfunc,ide_ele) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) SegTree([1]*n,segfunc,ide_ele) SegTree [1]*n [1] 1 n segfunc ide_ele seg=[SegTree([1]*n,segfunc,ide_ele) for _ in range(26)] seg [SegTree([1]*n,segfunc,ide_ele) for _ in range(26)] for i in range(n):
		seg[S[i]].update(i,0)
	
	 i range(n) range n seg[S[i]].update(i,0) [S[i]].update [S[i]] seg S[i] S i update i 0 q=II() q II() II for _ in range(q):
		a,b,c=input().split()
		if int(a)==1:
			b=int(b)-1
			seg[S[b]].update(b,1)
			t=ord(c)-ord("a")
			seg[t].update(b,0)
			S[b]=t
		
		else:
			#print(S)
			b=int(b)-1
			c=int(c)
			cnt=0
			for se in seg:
				if se.query(b,c)==0:
					cnt+=1
			print(cnt)
			
	
	 _ range(q) range q a,b,c=input().split() a input().split() ().split () input split b c if int(a)==1:
			b=int(b)-1
			seg[S[b]].update(b,1)
			t=ord(c)-ord("a")
			seg[t].update(b,0)
			S[b]=t
		
		else:
			#print(S)
			b=int(b)-1
			c=int(c)
			cnt=0
			for se in seg:
				if se.query(b,c)==0:
					cnt+=1
			print(cnt)
			
	
	 int(a)==1 int(a) int a 1 b=int(b)-1 b int(b)-1 int(b) int b 1 seg[S[b]].update(b,1) [S[b]].update [S[b]] seg S[b] S b update b 1 t=ord(c)-ord("a") t ord(c)-ord("a") ord(c) ord c ord("a") ord "a" seg[t].update(b,0) [t].update [t] seg t update b 0 S[b]=t S[b] S b t b=int(b)-1 b int(b)-1 int(b) int b 1 c=int(c) c int(c) int c cnt=0 cnt 0 for se in seg:
				if se.query(b,c)==0:
					cnt+=1
			 se seg if se.query(b,c)==0:
					cnt+=1
			 se.query(b,c)==0 se.query(b,c) se.query se query b c 0 cnt+=1 cnt 1 print(cnt) print cnt if __name__=="__main__":
	main() __name__=="__main__" __name__ "__main__" main() main class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        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番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        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):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        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:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        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番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        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):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        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 MF(): return map(float,input().split()) def MF(): return map(float,input().split()) MF def main():
	n=II()
	s=input().rstrip().decode()
	S=[]
	for i in s:
		S.append(ord(i)-ord("a"))
	
	seg=[SegTree([1]*n,segfunc,ide_ele) for _ in range(26)]
	
	#print(S)
	#print(seg)
	for i in range(n):
		seg[S[i]].update(i,0)
	
	q=II()
	for _ in range(q):
		a,b,c=input().split()
		if int(a)==1:
			b=int(b)-1
			seg[S[b]].update(b,1)
			t=ord(c)-ord("a")
			seg[t].update(b,0)
			S[b]=t
		
		else:
			#print(S)
			b=int(b)-1
			c=int(c)
			cnt=0
			for se in seg:
				if se.query(b,c)==0:
					cnt+=1
			print(cnt)
			
	
	 def main():
	n=II()
	s=input().rstrip().decode()
	S=[]
	for i in s:
		S.append(ord(i)-ord("a"))
	
	seg=[SegTree([1]*n,segfunc,ide_ele) for _ in range(26)]
	
	#print(S)
	#print(seg)
	for i in range(n):
		seg[S[i]].update(i,0)
	
	q=II()
	for _ in range(q):
		a,b,c=input().split()
		if int(a)==1:
			b=int(b)-1
			seg[S[b]].update(b,1)
			t=ord(c)-ord("a")
			seg[t].update(b,0)
			S[b]=t
		
		else:
			#print(S)
			b=int(b)-1
			c=int(c)
			cnt=0
			for se in seg:
				if se.query(b,c)==0:
					cnt+=1
			print(cnt)
			
	
	 main def TI(): return tuple(map(int,input().split()))

# rstrip().decode('utf-8')

#####segfunc##### def TI(): return tuple(map(int,input().split()))

# rstrip().decode('utf-8')

#####segfunc##### TI def II(): return int(input()) def II(): return int(input()) II def LF(): return list(map(float,input().split())) def LF(): return list(map(float,input().split())) LF ide_ele = 1 1 ide_ele def segfunc(x, y):
    return x*y
#################

#####ide_ele##### def segfunc(x, y):
    return x*y
#################

#####ide_ele##### segfunc def MI(): return map(int,input().split()) def MI(): return map(int,input().split()) MI input = sys.stdin.buffer.readline sys.stdin.buffer.readline input def RD(): return sys.stdin.read() def RD(): return sys.stdin.read() RD def LI(): return list(map(int,input().split())) def LI(): return list(map(int,input().split())) LI
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))

# rstrip().decode('utf-8')

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

#####ide_ele#####
ide_ele = 1
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        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番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        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):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        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

def main():
	n=II()
	s=input().rstrip().decode()
	S=[]
	for i in s:
		S.append(ord(i)-ord("a"))
	
	seg=[SegTree([1]*n,segfunc,ide_ele) for _ in range(26)]
	
	#print(S)
	#print(seg)
	for i in range(n):
		seg[S[i]].update(i,0)
	
	q=II()
	for _ in range(q):
		a,b,c=input().split()
		if int(a)==1:
			b=int(b)-1
			seg[S[b]].update(b,1)
			t=ord(c)-ord("a")
			seg[t].update(b,0)
			S[b]=t
		
		else:
			#print(S)
			b=int(b)-1
			c=int(c)
			cnt=0
			for se in seg:
				if se.query(b,c)==0:
					cnt+=1
			print(cnt)
			
	
	

if __name__=="__main__":
	main()
