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
# encoding: utf-8
from sys import stdin


def char_bit(c):
    return 1 << (ord(c) - ord('a'))


def count_bits(value):
    counter = 0
    while value:
        counter += value & 1
        value >>= 1
    return counter


class SegmentTree:
    def __init__(self, values, default, func):
        """
        Segment tree to find Value function for any segment of some array A.

        Suppose we want to find some V for every slice of a given array
        and that if we know values on slices [a:b] and [b:c] then it's easy to
        calculate value for slice [a:c] - in other words there exists associative binary
        operation ~ such that for any given a, b (where 0 <= a <= b < len(A))
            V(A[a:b]) = V(A[a:c]) ~ V(A[c:b]) for any c between a and b, particularly:
            V(A[a:b]) = V(A[a]) ~ V(A[a + 1]) ~ ... ~ V(A[b - 1])

        And suppose that we need to change separate values in array and keep results up to date.

        Example 1:
            ~ is min of two numbers and Value(array[a:b]) is minimum element on slice array[a:b]
        Example 2:
            ~ is addition and Value(array[a:b]) means sum of elements in A[a:b])

        Args:
            values:
                pre-calculated values for V function on elements of array
            default:
                value for empty segment, such that func(v, default) = v
            func:
                combining binary operation as function taking two arguments: func(a, b) means a ~ b
        """
        k = 0
        while 2 ** k < len(values):
            k += 1

        # heap_size = 2 ** (k + 1) - 1
        heap = (2 ** k - 1) * [default] + list(values) + (2 ** k - len(values)) * [default]
        for index in range(2 ** k - 1 - 1, -1, -1):
            heap[index] = func(heap[2 * index + 1], heap[2 * index + 2])

        self._length = len(values)
        self.func = func
        self.heap = heap
        self.k = k
        self.default = default

    def __getitem__(self, indexer):
        shift = 2 ** self.k - 1
        if isinstance(indexer, int):
            return self.heap[shift + indexer]
        elif isinstance(indexer, slice):
            left, right = shift + indexer.start, shift + indexer.stop - 1
            if left > right:
                return self.default
            func = self.func
            heap = self.heap
            res = func(heap[left], heap[right])
            while left < right:
                if ~(left & 1):
                    res = func(res, heap[left])
                    left += 1
                if right & 1:
                    res = func(res, heap[right])
                    right -= 1
                left = (left + 1) // 2 - 1
                right = (right + 1) // 2 - 1
                if left == right:
                    res = func(res, heap[left])
            return res
        raise TypeError()

    def __setitem__(self, array_index, value):
        if array_index > len(self):
            raise IndexError
        index = (2 ** self.k) - 1 + array_index
        heap = self.heap
        func = self.func
        heap[index] = value
        while index:
            # until there is an ancestor node in heap for current index
            index = (index + 1) // 2 - 1
            heap[index] = func(heap[2 * index + 1], heap[2 * index + 2])

    def __len__(self):
        return self._length


letters = stdin.readline().strip()
array = [char_bit(c) for c in letters]
segment_tree = SegmentTree(array, default=0, func=lambda x, y: x | y)

q = int(input())
for _ in range(q):
    query, a, b = stdin.readline().split()
    if query == '1':
        index = int(a) - 1
        segment_tree[index] = char_bit(b)
    else:
        start = int(a) - 1
        stop = int(b)
        print(count_bits(segment_tree[start:stop]))
