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 array import array
from collections import deque

letters = array('B', (ord(letter) for letter in input()))
q = int(input())

masks = {}
for i in range(ord('a'), ord('z') + 1):
    masks[i] = 1 << (i - ord('a'))


def count_bits(value):
    counter = 0
    while value:
        if value % 2:
            counter += 1
        value >>= 1
    return counter


def init_heap(heap, k):
    """Init heap if lowest level has index k (assuming top level has index 0)"""

    # init lowest level consisting of 2 ** k elements
    for index in range(2 ** k - 1, 2 ** k - 1 + 2 ** k):
        array_index = index - 2 ** k + 1
        if array_index < len(letters):
            heap[index] = masks[letters[array_index]]
        else:
            heap[index] = 0

    for level in range(k - 1, -1, -1):
        # init level
        for index in range(2 ** level - 1, 2 ** level - 1 + 2 ** level):
            heap[index] = heap[2 * index + 1] | heap[2 * index + 2]


def get_heap(array):
    k = 0
    while 2 ** k < len(array):
        k += 1
    heap_size = 2 ** (k + 1) - 1
    tree = heap_size * [0]
    init_heap(tree, k)
    return tree, k


def update_heap(heap, array_index, k):
    index = (2 ** k) - 1 + array_index
    heap[index] = masks[letters[array_index]]
    while index:
        # until there is an ancestor node in heap for current index
        if index % 2:
            index = index // 2
        else:
            index = index // 2 - 1
        tree[index] = tree[2 * index + 1] | tree[2 * index + 2]


def get(l, r, heap, k):
    """
    Find value for semi-segment [l, r).
    Split [l, r) into minimum set of fundamental semi-segments, then combine values for them.
    """
    result = 0
    q = deque([(l, r, 0, 0, 2 ** k)])
    while q:
        l, r, index, L, R = q.pop()
        if l == L and r == R:
            # semi-segment [L, R) is fundamental
            result |= heap[index]
        else:
            M = (L + R) // 2
            if r <= M:
                # reduce task to left subtree
                q.appendleft((l, r, 2 * index + 1, L, M))
            elif M <= l:
                # reduce task to right subtree
                q.appendleft((l, r, 2 * index + 2, M, R))
            else:
                # split task into left and right subtrees
                q.appendleft((l, M, 2 * index + 1, L, M))
                q.appendleft((M, r, 2 * index + 2, M, R))

    return result


tree, k = get_heap(letters)

for _ in range(q):
    query, a, b = input().split()
    if query == '1':
        index = int(a) - 1
        letters[index] = ord(b)
        update_heap(tree, index, k)
    else:
        start_index = int(a) - 1
        end_index = int(b) - 1
        print(count_bits(get(start_index, end_index + 1, tree, k)))
