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.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class DDistinctCharactersQueries {
        static DDistinctCharactersQueries.Node[] st;
        static StringBuilder s;

        int getMid(int s, int e) {
            return s + (e - s) / 2;
        }

        DDistinctCharactersQueries.Node MaxUtil(int ss, int se, int l,
                                                int r, int node) {
            if (l <= ss && r >= se)
                return st[node];

            if (se < l || ss > r)
                return new DDistinctCharactersQueries.Node();

            int mid = getMid(ss, se);

            DDistinctCharactersQueries.Node a = MaxUtil(ss, mid, l, r, 2 * node + 1);
            DDistinctCharactersQueries.Node b = MaxUtil(mid + 1, se, l, r, 2 * node + 2);
            DDistinctCharactersQueries.Node act = new DDistinctCharactersQueries.Node();
            for (int i = 0; i < 26; i++) {
                act.k[i] = a.k[i] + b.k[i];
            }
            return act;
        }

        void updateValue(int ss, int se,
                         int index, char value, int node) {
            if (ss == se) {
                s.setCharAt(index, value);
                st[node] = new DDistinctCharactersQueries.Node();
                st[node].k[value - 'a']++;
            } else {
                int mid = getMid(ss, se);
                if (index >= ss && index <= mid)
                    updateValue(ss, mid, index, value, 2 * node + 1);
                else
                    updateValue(mid + 1, se, index, value, 2 * node + 2);

                DDistinctCharactersQueries.Node a = st[2 * node + 1];
                DDistinctCharactersQueries.Node b = st[2 * node + 2];
                for (int i = 0; i < 26; i++) {
                    st[node].k[i] = a.k[i] + b.k[i];
                }
            }
        }

        DDistinctCharactersQueries.Node getMax(int n, int l, int r) {
            return MaxUtil(0, n - 1, l, r, 0);
        }

        DDistinctCharactersQueries.Node constructSTUtil(int ss, int se, int si) {
            if (ss == se) {
                st[si] = new DDistinctCharactersQueries.Node();
                st[si].k[s.charAt(ss) - 'a']++;
                return st[si];
            }

            int mid = getMid(ss, se);
            DDistinctCharactersQueries.Node a = constructSTUtil(ss, mid, si * 2 + 1);
            DDistinctCharactersQueries.Node b = constructSTUtil(mid + 1, se, si * 2 + 2);
            st[si] = new DDistinctCharactersQueries.Node();
            for (int i = 0; i < 26; i++) {
                st[si].k[i] = a.k[i] + b.k[i];
            }
            return st[si];
        }

        void constructST(int n) {
            int x = (int) (Math.ceil(Math.log(n) / Math.log(2)));
            int max_size = 2 * (1 << x) - 1;
            st = new DDistinctCharactersQueries.Node[max_size];
            constructSTUtil(0, n - 1, 0);
        }

        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            s = new StringBuilder(sc.nextLine());
            int n = s.length();
            constructST(s.length());
            int q = sc.nextInt();
            for (int i = 0; i < q; i++) {
                String[] line = sc.nextLine().split(" ");
                int t = Integer.parseInt(line[0]);
                if (t == 1) {
                    int x = Integer.parseInt(line[1]) - 1;
                    char c = line[2].charAt(0);
                    updateValue(0, n - 1, x, c, 0);
                } else {
                    int l = Integer.parseInt(line[1]) - 1;
                    int r = Integer.parseInt(line[2]) - 1;
                    DDistinctCharactersQueries.Node act = getMax(n, l, r);
                    int ans = 0;
                    for (int j = 0; j < 26; j++) {
                        if (act.k[j] > 0) {
                            ans++;
                        }
                    }
                    out.println(ans);
                }


            }
        }

        static class Node {
            int[] k;

            public Node() {
                this.k = new int[26];
            }

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

