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.*;
import java.util.*;
public class Q2 {

    public static int range(int tree[][], int l, int r, int index, int i, int left, int right) {

        if (l > r || right < l || left > r)
            return 0;

        if (left <= l && r <=right)
            return tree[i][index];

        int mid = (l + r) / 2;

        int temp=range(tree, l, mid, index * 2, i, left, right)+range(tree, mid + 1, r, index * 2 + 1, i, left, right);

        return temp==0 ?0 :1;

    }

    public static void update(int tree[][], int l, int r, int index, int i, int pos, int val) {

        if (l > r)
            return;

        if (l == r && l == pos) {
            tree[i][index] = val;
            return;
        }


        int mid = (l + r) / 2;
        if (mid >= pos)
            update(tree, l, mid, index * 2, i, pos, val);
        else
            update(tree, mid + 1, r, index * 2 + 1, i, pos, val);

        tree[i][index] = (tree[i][2 * index] + tree[i][2 * index + 1])== 0 ? 0 : 1;

    }

    public static void main(String[] args) {

        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);

        char arr[] = in.next().toCharArray();
        int N = arr.length;

        int input[][] = new int[26][N];
        int tree[][] = new int[26][4 * N];


        for (int i = 0; i < N; i++) {
            input[arr[i] - 'a'][i]++;
            update(tree, 0, N - 1, 1, arr[i]-'a', i, 1);

        }



        int t = in.nextInt();

        while (t-- > 0) {
            int a = in.nextInt(), b = in.nextInt();

            if (a == 1) {
                char ne = in.nextChar();
                char prv = arr[b - 1];
                arr[b-1]=ne;

                update(tree, 0, N - 1, 1, prv - 'a', b - 1, 0);
                update(tree, 0, N - 1, 1, ne - 'a', b - 1, 1);

            } else {
                int c = in.nextInt(),ans = 0;
                for (int i = 0; i < 26; i++)
                    ans+=range(tree, 0, N - 1, 1, i, b - 1, c - 1);


                out.println(ans);

            }
        }

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;


        public int[] shuffle(int[] arr) {
            Random r = new Random();
            for (int i = 1, j; i < arr.length; i++) {
                j = r.nextInt(i);
                arr[i] = arr[i] ^ arr[j];
                arr[j] = arr[i] ^ arr[j];
                arr[i] = arr[i] ^ arr[j];
            }
            return arr;
        }

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }


    }

}