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 Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String s = sc.nextLine();
        int q = sc.nextInt();
        SegmentTree st = new SegmentTree(s);
        while (q -- > 0) {
            int type = sc.nextInt();
            if (type == 1)
                st.update_point(sc.nextInt(), sc.next().charAt(0));
            else out.println(st.query(sc.nextInt(), sc.nextInt()));
        }

        out.close();
        out.flush();
    }

    static class SegmentTree {
        int N;
        Character[] arr;
        int[][] sTree;
        public SegmentTree(String s) {
            int n = s.length();
            N = 1;
            while (N < n) N <<= 1;
            this.arr = new Character[N + 1];
            for (int i = 1; i <= s.length(); ++i)
                this.arr[i] = s.charAt(i - 1);
            //N--;
            sTree = new int[N << 1][26];
            build(1, 1, N);
        }

        int[] merge(int[] l, int[] r) {
            int[] cnt = new int[26];
            for (int i = 0; i < 26; ++i)
                cnt[i] = l[i] + r[i];
            return cnt;
        }

        void build(int node, int b, int e) {
            if(b == e) {
                int[] cnt = new int[26];
                if (arr[b] != null)
                    cnt[arr[b] - 'a']++;
                sTree[node] = cnt;
            } else {
                int mid = b + e >> 1;
                build(node<<1,b,mid);
                build(node<<1|1,mid+1,e);
                sTree[node] = merge(sTree[node<<1], sTree[node<<1|1]);
            }
        }


        void update_point(int index, char newChar) {
            index += N - 1;
            int[] cnt = new int[26];
            cnt[newChar - 'a']++;
            sTree[index] = cnt;
            while(index>1) {
                index >>= 1;
                sTree[index] = merge(sTree[index<<1], sTree[index<<1|1]);
            }
        }

        int query(int i, int j) {
            int[] ret = query(1,1,N,i,j);
            int cnt = 0;
            for (int k = 0; k < 26; ++k)
                if (ret[k] > 0)
                    cnt++;
            return cnt;
        }


        int[] query(int node, int b, int e, int i, int j) {
            if(i > e || j < b)
                return new int[26];
            if(b >= i && e <= j)
                return sTree[node];
            int mid = b + e >> 1;
            return merge(query(node<<1,b,mid,i,j), query(node<<1|1,mid+1,e,i,j));
        }


    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}
