import sys
input=sys.stdin.readline
n=int(input())
BIT=[[0]*n for i in range(26)]
w=[ord(x)-ord("a") for x in input()]
for i in range(n):
	k=i+1
	while k<=n:
		BIT[w[i]][k-1]+=1
		k=k+(k&-k)
q=int(input())
for i in range(q):
	a,b,c=input().split()
	if a=="1":
		k=int(b)
		while k<=n:
			BIT[ord(c)-ord("a")][k-1]+=1
			k=k+(k&-k)
		k=int(b)
		while k<=n:
			BIT[w[int(b)-1]][k-1]-=1
			k=k+(k&-k)	
		w[int(b)-1]=ord(c)-ord("a")
	else:
		b=int(b);c=int(c)
		ans=0
		for i in range(26):
			cnt=0
			k=c
			while k!=0:
				cnt+=BIT[i][k-1]
				k=k-(k&-k)
			k=b-1
			while k!=0:
				cnt-=BIT[i][k-1]
				k=k-(k&-k)
			if cnt>0:
				ans+=1
		print(ans) 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 [0]*n for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) [0]*n [0] 0 n BIT=[[0]*n for i in range(26)] BIT [[0]*n for i in range(26)] ord(x)-ord("a") for x in input() for x in input() x input() input for x in input() ord(x)-ord("a") ord(x) ord x ord("a") ord "a" w=[ord(x)-ord("a") for x in input()] w [ord(x)-ord("a") for x in input()] for i in range(n):
	k=i+1
	while k<=n:
		BIT[w[i]][k-1]+=1
		k=k+(k&-k) i range(n) range n k=i+1 k i+1 i 1 while k<=n:
		BIT[w[i]][k-1]+=1
		k=k+(k&-k) k<=n k n BIT[w[i]][k-1]+=1 BIT[w[i]][k-1] [w[i]] BIT w[i] w i k-1 k 1 1 k=k+(k&-k) k k+(k&-k) k k&-k k -k k q=int(input()) q int(input()) int input() input for i in range(q):
	a,b,c=input().split()
	if a=="1":
		k=int(b)
		while k<=n:
			BIT[ord(c)-ord("a")][k-1]+=1
			k=k+(k&-k)
		k=int(b)
		while k<=n:
			BIT[w[int(b)-1]][k-1]-=1
			k=k+(k&-k)	
		w[int(b)-1]=ord(c)-ord("a")
	else:
		b=int(b);c=int(c)
		ans=0
		for i in range(26):
			cnt=0
			k=c
			while k!=0:
				cnt+=BIT[i][k-1]
				k=k-(k&-k)
			k=b-1
			while k!=0:
				cnt-=BIT[i][k-1]
				k=k-(k&-k)
			if cnt>0:
				ans+=1
		print(ans) i range(q) range q a,b,c=input().split() a input().split() ().split () input split b c if a=="1":
		k=int(b)
		while k<=n:
			BIT[ord(c)-ord("a")][k-1]+=1
			k=k+(k&-k)
		k=int(b)
		while k<=n:
			BIT[w[int(b)-1]][k-1]-=1
			k=k+(k&-k)	
		w[int(b)-1]=ord(c)-ord("a")
	else:
		b=int(b);c=int(c)
		ans=0
		for i in range(26):
			cnt=0
			k=c
			while k!=0:
				cnt+=BIT[i][k-1]
				k=k-(k&-k)
			k=b-1
			while k!=0:
				cnt-=BIT[i][k-1]
				k=k-(k&-k)
			if cnt>0:
				ans+=1
		print(ans) a=="1" a "1" k=int(b) k int(b) int b while k<=n:
			BIT[ord(c)-ord("a")][k-1]+=1
			k=k+(k&-k)
		 k<=n k n BIT[ord(c)-ord("a")][k-1]+=1 BIT[ord(c)-ord("a")][k-1] [ord(c)-ord("a")] BIT ord(c)-ord("a") ord(c) ord c ord("a") ord "a" k-1 k 1 1 k=k+(k&-k) k k+(k&-k) k k&-k k -k k k=int(b) k int(b) int b while k<=n:
			BIT[w[int(b)-1]][k-1]-=1
			k=k+(k&-k)	
		 k<=n k n BIT[w[int(b)-1]][k-1]-=1 BIT[w[int(b)-1]][k-1] [w[int(b)-1]] BIT w[int(b)-1] w int(b)-1 int(b) int b 1 k-1 k 1 1 k=k+(k&-k) k k+(k&-k) k k&-k k -k k w[int(b)-1]=ord(c)-ord("a") w[int(b)-1] w int(b)-1 int(b) int b 1 ord(c)-ord("a") ord(c) ord c ord("a") ord "a" b=int(b) b int(b) int b c=int(c) c int(c) int c ans=0 ans 0 for i in range(26):
			cnt=0
			k=c
			while k!=0:
				cnt+=BIT[i][k-1]
				k=k-(k&-k)
			k=b-1
			while k!=0:
				cnt-=BIT[i][k-1]
				k=k-(k&-k)
			if cnt>0:
				ans+=1
		 i range(26) range 26 cnt=0 cnt 0 k=c k c while k!=0:
				cnt+=BIT[i][k-1]
				k=k-(k&-k)
			 k!=0 k 0 cnt+=BIT[i][k-1] cnt BIT[i][k-1] [i] BIT i k-1 k 1 k=k-(k&-k) k k-(k&-k) k k&-k k -k k k=b-1 k b-1 b 1 while k!=0:
				cnt-=BIT[i][k-1]
				k=k-(k&-k)
			 k!=0 k 0 cnt-=BIT[i][k-1] cnt BIT[i][k-1] [i] BIT i k-1 k 1 k=k-(k&-k) k k-(k&-k) k k&-k k -k k if cnt>0:
				ans+=1
		 cnt>0 cnt 0 ans+=1 ans 1 print(ans) print ans k=b-1 b-1 k c=int(c) int(c) c cnt-=BIT[i][k-1] BIT[i][k-1] cnt k=c c k cnt+=BIT[i][k-1] BIT[i][k-1] cnt k=k+(k&-k) k+(k&-k) k ans+=1 1 ans w=[ord(x)-ord("a") for x in input()] [ord(x)-ord("a") for x in input()] w b,c=input().split() input().split() b k=int(b) int(b) k k=k+(k&-k) k+(k&-k) k a,b,c=input().split() input().split() a k=k+(k&-k) k+(k&-k) k q=int(input()) int(input()) q k=k-(k&-k) k-(k&-k) k BIT=[[0]*n for i in range(26)] [[0]*n for i in range(26)] BIT c=input().split() input().split() c b=int(b) int(b) b k=int(b) int(b) k input=sys.stdin.readline sys.stdin.readline input k=k-(k&-k) k-(k&-k) k ans=0 0 ans k=i+1 i+1 k n=int(input()) int(input()) n cnt=0 0 cnt
import sys
input=sys.stdin.readline
n=int(input())
BIT=[[0]*n for i in range(26)]
w=[ord(x)-ord("a") for x in input()]
for i in range(n):
	k=i+1
	while k<=n:
		BIT[w[i]][k-1]+=1
		k=k+(k&-k)
q=int(input())
for i in range(q):
	a,b,c=input().split()
	if a=="1":
		k=int(b)
		while k<=n:
			BIT[ord(c)-ord("a")][k-1]+=1
			k=k+(k&-k)
		k=int(b)
		while k<=n:
			BIT[w[int(b)-1]][k-1]-=1
			k=k+(k&-k)	
		w[int(b)-1]=ord(c)-ord("a")
	else:
		b=int(b);c=int(c)
		ans=0
		for i in range(26):
			cnt=0
			k=c
			while k!=0:
				cnt+=BIT[i][k-1]
				k=k-(k&-k)
			k=b-1
			while k!=0:
				cnt-=BIT[i][k-1]
				k=k-(k&-k)
			if cnt>0:
				ans+=1
		print(ans)