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 java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kamlesh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DistinctChars2 solver = new DistinctChars2();
        solver.solve(1, in, out);
        out.close();
    }

    static class DistinctChars2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {


            char arr[] = in.next().trim().toCharArray();
            int n = arr.length;
            Node tree[] = new Node[4 * n];

            n = n - 1;
            buildTree(arr, tree, 0, n, 1);

            //      System.out.println(Arrays.toString(tree));
            int q = in.nextInt();

            while (q-- > 0) {
                String s = in.next();
                if (s.equals("1")) {
                    int idx = in.nextInt() - 1;
                    updateTree(arr, tree, 0, n, 1, idx, arr[idx], in.next().charAt(0));
                } else {
                    Node ans = query(tree, 0, n, 1, in.nextInt() - 1, in.nextInt() - 1);
                    out.println(ans.distinct());
                }
            }

        }

        void buildTree(char arr[], Node[] tree, int start, int end, int treeNode) {
            if (start == end) {
                tree[treeNode] = new Node(arr[start]);
                return;
            }

            int mid = (start + end) / 2;
            buildTree(arr, tree, start, mid, 2 * treeNode);
            buildTree(arr, tree, mid + 1, end, 2 * treeNode + 1);

            tree[treeNode] = new Node(tree[2 * treeNode], tree[2 * treeNode + 1]);

        }

        void updateTree(char arr[], Node[] tree, int start, int end, int treeNode, int idx, char oldval, char newval) {
            if (start == end) {
                arr[idx] = newval;
                tree[treeNode].edit(oldval, newval);
                return;
            }
            int mid = (start + end) / 2;
            if (idx > mid) {
                updateTree(arr, tree, mid + 1, end, 2 * treeNode + 1, idx, oldval, newval);
            } else {
                updateTree(arr, tree, start, mid, 2 * treeNode, idx, oldval, newval);
            }

            tree[treeNode].edit(oldval, newval);
        }

        Node query(Node[] tree, int start, int end, int treeNode, int left, int right) {

            //completely outside the given range

            if (start > right || end < left) {
                return new Node();
            }

            //completely inside given range
            if (start >= left && end <= right) {
                return tree[treeNode];
            }

            //partially inside and partially outside
            int mid = (start + end) / 2;
            Node ans1 = query(tree, start, mid, 2 * treeNode, left, right);
            Node ans2 = query(tree, mid + 1, end, 2 * treeNode + 1, left, right);


            Node ans = new Node(ans1, ans2);

            return ans;
        }

        class Node {
            int[] map;

            public Node() {
                map = new int[26];
            }

            public Node(char ch) {
                map = new int[26];
                map[ch - 'a']++;
            }

            public Node(Node left, Node right) {
                map = new int[26];
                for (int i = 0; i < 26; i++) {
                    map[i] = left.map[i] + right.map[i];
                }
            }

            void decrease_count(char ch) {

                if (map[ch - 'a'] > 0) {
                    map[ch - 'a']--;
                }
            }

            void increase_count(char ch) {
                map[ch - 'a']++;
            }

            void edit(char oldval, char newval) {
                decrease_count(oldval);
                increase_count(newval);
            }

            int distinct() {
                int count = 0;
                for (int item : map)
                    if (item > 0) count++;
                return count;
            }

            public String toString() {
                return Arrays.toString(map);
            }

        }

    }
}

