n = int(input())
stmp = list(input())
Q = int(input())
target = ord("a")
s = [ord(stmp[i])-target for i in range(n)]

class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
	
	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def __init__(self, n):
		self.bitlen = n+1
		self.bit = [0]*(n+1)

b = [BIT(n) for i in range(26)]
for i in range(n):
	b[s[i]].add(i, 1)

for _ in range(Q):
	q,qtmpa,qtmpb = input().split()
	if q[0] == "1":
		qa = int(qtmpa)
		t = ord(qtmpb)-target
		b[t].add(qa-1, 1)
		b[s[qa-1]].add(qa-1, -1)
		s[qa-1] = t
	else:
		ans = 0
		qta = int(qtmpa)
		qtb = int(qtmpb)
		for i in range(26):
			if b[i].sum(qta-1, qtb) != 0:
				ans += 1
		print(ans) n = int(input()) n int(input()) int input() input stmp = list(input()) stmp list(input()) list input() input Q = int(input()) Q int(input()) int input() input target = ord("a") target ord("a") ord "a" ord(stmp[i])-target for i in range(n) for i in range(n) i range(n) range n for i in range(n) ord(stmp[i])-target ord(stmp[i]) ord stmp[i] stmp i target s = [ord(stmp[i])-target for i in range(n)] s [ord(stmp[i])-target for i in range(n)] class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
	
	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def __init__(self, n):
		self.bitlen = n+1
		self.bit = [0]*(n+1) BIT """
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	""" def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	 query res = 0 res 0 while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		 m > 0 m 0 res += self.bit[m] res self.bit[m] self.bit self bit m m -= m&(-m) m m&(-m) m -m m return res res self self m m def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	 sum return self.query(b)-self.query(a) self.query(b)-self.query(a) self.query(b) self.query self query b self.query(a) self.query self query a self self a a b b def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
	
	 sumall bitlen = self.bitlen-1 bitlen self.bitlen-1 self.bitlen self bitlen 1 return self.query(bitlen) self.query(bitlen) self.query self query bitlen self self def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	 add m += 1 m 1 bitlen = len(self.bit) bitlen len(self.bit) len self.bit self bit while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		 m <= bitlen-1 m bitlen-1 bitlen 1 self.bit[m] += x self.bit[m] self.bit self bit m x m += m&(-m) m m&(-m) m -m m return self self m m x x def __init__(self, n):
		self.bitlen = n+1
		self.bit = [0]*(n+1) __init__ self.bitlen = n+1 self.bitlen self bitlen n+1 n 1 self.bit = [0]*(n+1) self.bit self bit [0]*(n+1) [0] 0 n+1 n 1 self self n n BIT(n) for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) BIT(n) BIT n b = [BIT(n) for i in range(26)] b [BIT(n) for i in range(26)] for i in range(n):
	b[s[i]].add(i, 1) i range(n) range n b[s[i]].add(i, 1) [s[i]].add [s[i]] b s[i] s i add i 1 for _ in range(Q):
	q,qtmpa,qtmpb = input().split()
	if q[0] == "1":
		qa = int(qtmpa)
		t = ord(qtmpb)-target
		b[t].add(qa-1, 1)
		b[s[qa-1]].add(qa-1, -1)
		s[qa-1] = t
	else:
		ans = 0
		qta = int(qtmpa)
		qtb = int(qtmpb)
		for i in range(26):
			if b[i].sum(qta-1, qtb) != 0:
				ans += 1
		print(ans) _ range(Q) range Q q,qtmpa,qtmpb = input().split() q input().split() ().split () input split qtmpa qtmpb if q[0] == "1":
		qa = int(qtmpa)
		t = ord(qtmpb)-target
		b[t].add(qa-1, 1)
		b[s[qa-1]].add(qa-1, -1)
		s[qa-1] = t
	else:
		ans = 0
		qta = int(qtmpa)
		qtb = int(qtmpb)
		for i in range(26):
			if b[i].sum(qta-1, qtb) != 0:
				ans += 1
		print(ans) q[0] == "1" q[0] q 0 "1" qa = int(qtmpa) qa int(qtmpa) int qtmpa t = ord(qtmpb)-target t ord(qtmpb)-target ord(qtmpb) ord qtmpb target b[t].add(qa-1, 1) [t].add [t] b t add qa-1 qa 1 1 b[s[qa-1]].add(qa-1, -1) [s[qa-1]].add [s[qa-1]] b s[qa-1] s qa-1 qa 1 add qa-1 qa 1 -1 s[qa-1] = t s[qa-1] s qa-1 qa 1 t ans = 0 ans 0 qta = int(qtmpa) qta int(qtmpa) int qtmpa qtb = int(qtmpb) qtb int(qtmpb) int qtmpb for i in range(26):
			if b[i].sum(qta-1, qtb) != 0:
				ans += 1
		 i range(26) range 26 if b[i].sum(qta-1, qtb) != 0:
				ans += 1
		 b[i].sum(qta-1, qtb) != 0 b[i].sum(qta-1, qtb) [i].sum [i] b i sum qta-1 qta 1 qtb 0 ans += 1 ans 1 print(ans) print ans qtmpb = input().split() input().split() qtmpb s = [ord(stmp[i])-target for i in range(n)] [ord(stmp[i])-target for i in range(n)] s qtmpa,qtmpb = input().split() input().split() qtmpa ans = 0 0 ans class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
	
	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def __init__(self, n):
		self.bitlen = n+1
		self.bit = [0]*(n+1) class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
	
	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def __init__(self, n):
		self.bitlen = n+1
		self.bit = [0]*(n+1) BIT qta = int(qtmpa) int(qtmpa) qta n = int(input()) int(input()) n b = [BIT(n) for i in range(26)] [BIT(n) for i in range(26)] b Q = int(input()) int(input()) Q ans += 1 1 ans target = ord("a") ord("a") target qa = int(qtmpa) int(qtmpa) qa qtb = int(qtmpb) int(qtmpb) qtb stmp = list(input()) list(input()) stmp q,qtmpa,qtmpb = input().split() input().split() q t = ord(qtmpb)-target ord(qtmpb)-target t
n = int(input())
stmp = list(input())
Q = int(input())
target = ord("a")
s = [ord(stmp[i])-target for i in range(n)]

class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
	
	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def __init__(self, n):
		self.bitlen = n+1
		self.bit = [0]*(n+1)

b = [BIT(n) for i in range(26)]
for i in range(n):
	b[s[i]].add(i, 1)

for _ in range(Q):
	q,qtmpa,qtmpb = input().split()
	if q[0] == "1":
		qa = int(qtmpa)
		t = ord(qtmpb)-target
		b[t].add(qa-1, 1)
		b[s[qa-1]].add(qa-1, -1)
		s[qa-1] = t
	else:
		ans = 0
		qta = int(qtmpa)
		qtb = int(qtmpb)
		for i in range(26):
			if b[i].sum(qta-1, qtb) != 0:
				ans += 1
		print(ans)
