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 BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        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 = os.read(self._fd, max(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 = os.read(self._fd, max(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:
            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")

from types import GeneratorType


def iterative(f, stack=[]):
    def wrapped_func(*args, **kwargs):
        if stack: return f(*args, **kwargs)
        to = f(*args, **kwargs)
        while True:
            if type(to) is GeneratorType:
                stack.append(to)
                to = next(to)
                continue
            stack.pop()
            if not stack: break
            to = stack[-1].send(to)
        return to

    return wrapped_func


def build_segment(a, tree, i_tree, right, left):
    if right == left:
        tree[i_tree] = 1 << a[right]
        return
    else:
        mid = (right + left) // 2
        build_segment(a, tree, 2 * i_tree, right, mid)
        build_segment(a, tree, 2 * i_tree + 1, mid + 1, left)
        if tree[i_tree * 2] == 67108863 or tree[i_tree * 2 + 1] == 67108863:
            tree[i_tree] = 67108863
        else:
            tree[i_tree] = tree[i_tree * 2] | tree[i_tree * 2 + 1]
        return



def update(a, tree, i_tree, left, right, i, ch):
    if right == left == i:
        tree[i_tree] = 1 << ch
    elif left <= i <= right:
        mid = (right + left) // 2
        update(a, tree, i_tree * 2, left, mid, i, ch)
        update(a, tree, i_tree * 2 + 1, mid + 1, right, i, ch)
        if tree[i_tree * 2] == 67108863 or tree[i_tree * 2 + 1] == 67108863:
            tree[i_tree] = 67108863
        else:
            tree[i_tree] = tree[i_tree * 2] | tree[i_tree * 2 + 1]
    return


def querry(tree, i_tree, left, right, ql, qr, s):
    if qr < left or ql > right:
        return
    if ql <= left and right <= qr:
        if s[0] < 67108863:
            s[0] |= tree[i_tree]
    else:
        mid = (right + left) // 2
        querry(tree, 2 * i_tree, left, mid, ql, qr, s)
        querry(tree, 2 * i_tree + 1, mid + 1, right, ql, qr, s)
    return


def dtb(n):
    return bin(n).replace("0b", "")


a = [ord(i) - 97 for i in input()]
t = [0] * (4 * len(a) + 1)
build_segment(a, t, 1, 0, len(a) - 1)
chec = dict()
for _ in range(int(input())):
    ck, x, y = input().split()
    if int(ck) == 1:
        chec[int(x)] = y
    else:
        for i in chec:
            x1 = i
            y1 = chec[i]
            if a[int(x1) - 1] == ord(y1) - 97:
                continue
            update(a, t, 1, 0, len(a) - 1, int(x1) - 1, ord(y1) - 97)
            a[int(x1) - 1] = ord(y1) - 97
        s = [0]
        querry(t, 1, 0, len(a) - 1, int(x) - 1, int(y) - 1, s)
        print(dtb(s[0]).count('1'))
        chec = dict()