You are given a string s consisting of lowercase Latin letters and q queries for this string.

Recall that the substring s[l; r] of the string s is the string s_l s_{l + 1} ... s_r. For example, the substrings of "codeforces" are "code", "force", "f", "for", but not "coder" and "top".

There are two types of queries: 

  * 1~ pos~ c (1 ≤ pos ≤ |s|, c is lowercase Latin letter): replace s_{pos} with c (set s_{pos} := c); 
  * 2~ l~ r (1 ≤ l ≤ r ≤ |s|): calculate the number of distinct characters in the substring s[l; r]. 

Input

The first line of the input contains one string s consisting of no more than 10^5 lowercase Latin letters.

The second line of the input contains one integer q (1 ≤ q ≤ 10^5) — the number of queries.

The next q lines contain queries, one per line. Each query is given in the format described in the problem statement. It is guaranteed that there is at least one query of the second type.

Output

For each query of the second type print the answer for it — the number of distinct characters in the required substring in this query.

Examples

Input


abacaba
5
2 1 4
1 4 b
1 5 b
2 4 6
2 1 7


Output


3
1
2


Input


dfcbbcfeeedbaea
15
1 6 e
1 4 b
2 6 14
1 7 b
1 12 c
2 6 8
2 1 6
1 7 c
1 2 f
1 10 a
2 7 9
1 10 a
1 14 b
1 1 f
2 1 11


Output


5
2
5
2
6
import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange
BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
 
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None
 
    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
 
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()
 
    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
 
# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

dv=str(input())
n=len(dv)
v={}
for i in range(n):
	v[i]=dv[i]
q=int(input())

tree=[[0 for j in range(26)] for i in range(4*n+5)]
node={}
aze={}
aze[0]=(0,n-1)
def build():
	r=[0]
	while r:
		i=r.pop()
		s,e=aze[i]
		if e<s:continue
		if e==s:
			b=ord(v[e])-ord('a')
			tree[i][b]=1
			node[e]=i
			j=(i-1)//2
			while j!=0:
				tree[j][b]+=1
				j=(j-1)//2
			tree[0][b]+=1
			continue
		aze[2*i+1]=(s,s+(e-s)//2)
		aze[2*i+2]=(s+(e-s)//2+1,e)
		r.append(2*i+1)
		r.append(2*i+2)
build()
def quer(s,e):
	r=[0]
	ans=[0 for i in range(26)]
	while r:
		i=r.pop()
		ss,se=aze[i]
		if s>se or e<ss:continue
		if s<=ss and e>=se:
			for j in range(26):
				ans[j]+=tree[i][j]
			continue
		r.append(2*i+1)
		r.append(2*i+2)
	return(26-ans.count(0))


def upd(i,p):
	j=node[i]
	b=ord(p)-ord('a')
	c=ord(v[i])-ord('a')
	tree[j][c]-=1
	tree[j][b]+=1
	j=(j-1)//2
	while j!=0:
		tree[j][c]-=1
		tree[j][b]+=1
		j=(j-1)//2
	tree[0][c]-=1
	tree[0][b]+=1

for i in range(q):
	c,a,b=input().split()
	if int(c)==1:
		i=int(a)-1
		upd(i,b)
		v[i]=b
	else:
		print(quer(int(a)-1,int(b)-1))