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
import sys
from io import BytesIO, IOBase
 
from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        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")
 
import time
start_time = time.time()

import collections as col
import math
from functools import reduce

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())



"""
Each leaf of the Segment Tree is [0,0,0,1,0,0...] where 1 represents that letter
When we update the leaf, we need only update the indices we are swapping
When we query, we want to know how many positions Q[R] > Q[L-1]
"""

def solve():
    def build(arr) : 
        for i in range(n) :
            x = ord(arr[i])-ord('a')
            tree[n + i] = [0]*26
            if 0 <= x <= 25:
                tree[n + i][x] = 1
        for i in range(n - 1, 0, -1) :
            a, b = tree[i << 1], tree[i << 1 | 1]
            tree[i] = [a[j]|b[j] for j in range(26)]
      
    def updateTreeNode(p, old_value, new_value):
        x = ord(old_value)-ord('a')
        y = ord(new_value)-ord('a')
        tree[p + n][x] = 0
        tree[p + n][y] = 1
        i = p + n
        
        while i > 1:
            i >>= 1
            a, b = tree[i << 1], tree[i << 1 | 1]
            tree[i][x] = a[x]|b[x]
            tree[i][y] = a[y]|b[y]
    
    def query(l, r):  
        res = [0]*26
        l += n
        r += n 
        while l < r: 
            if (l & 1): 
                for j in range(26):
                    
                    res[j] |= tree[l][j]
                l += 1
            if (r & 1):
                r -= 1
                for j in range(26):
                    res[j] |= tree[r][j]
            l >>= 1
            r >>= 1
        return sum(res)
    S = listStr()
    n = len(S)
    q = getInt()
    tree = ['']*(2*n)
    while len(S) < n:
        S.append('.')
    build(S)
    for qq in range(q):
        A, B, C = getStrs()
        A = int(A)
        B = int(B)
        B -= 1
        if A == 1:
            updateTreeNode(B,S[B],C)
            S[B] = C
        else:
            print(query(B,int(C)))
    return
            
    
#for _ in range(getInt()):    
solve()

 
