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.math.BigInteger;
import java.util.*;
import static java.lang.Math.PI;
import static java.lang.System.in;
import static java.lang.System.out;
import static java.lang.System.err;

public class D {    
    static class Node{
        int bit;
        Node left, right;
        public Node(){
            this.bit = 0;
        }
    }
    static class SegmentTree{
        public Node root;
        public SegmentTree(char a[]){
            this.root = buildTree(0, a.length-1, a);
        }
        private int getKthBit(char ch){
            return (int)(ch-'a');
        }
        private int setKthBit(int num, int k){
            num = num | (1<<k);
            return num;
        }
        private Node buildTree(int L, int R, char a[]){
            if(L == R){
                Node newNode = new Node();
                newNode.bit = setKthBit(newNode.bit, getKthBit(a[L]));
                return newNode;
            }
            int mid = L + (R-L)/2;
            Node newNode = new Node();
            newNode.left = buildTree(L, mid, a);
            newNode.right = buildTree(mid+1, R, a);
            newNode.bit = newNode.right.bit | newNode.left.bit;
            return newNode;
        }
        public int queryMin(Node current, int L, int R, int qL, int qR){
            if(qL <= L && qR >= R){
                return current.bit;
            }
            if(qL > R || qR < L){
                return 0;
            }
            int mid = L + (R-L)/2;
            int left = queryMin(current.left, L, mid, qL, qR);
            int right = queryMin(current.right, mid+1, R, qL, qR);
            int temp = left | right;
            return temp;
        }
        public void pointUpdate(Node current, int L, int R, int idx, char val){
            if(L == idx && R == idx){
                int bit = 0;
                bit = setKthBit(bit, getKthBit(val));
                current.bit = bit;
                return;
            }
            int mid = L + (R-L)/2;
            if(L <= idx && idx <= mid){
                pointUpdate(current.left, L, mid, idx, val);
            }
            else{
                pointUpdate(current.right, mid+1, R, idx, val);
            }
            int bit = current.left.bit | current.right.bit;
            current.bit = bit;
        }
    }
    static public void main(String... args) throws Exception {   
        Foster sc = new Foster();
        PrintWriter p = new PrintWriter(out);
        char a[] = sc.next().toCharArray();
        SegmentTree tree = new SegmentTree(a);
        int q = sc.nextInt();
        while(q--!=0){
            int type = sc.nextInt();
            if(type==2){
                int L = sc.nextInt(), R = sc.nextInt();
                L--;
                R--;
                int ans = tree.queryMin(tree.root, 0, a.length-1, L, R);
                p.println(Integer.bitCount(ans));
            }
            else{
                int idx = sc.nextInt();
                char val = sc.next().charAt(0);
                idx--;
                tree.pointUpdate(tree.root, 0, a.length-1, idx, val);
            }
        }
        p.close();
    }
    
    static long[] sort(long a[]){
        ArrayList<Long> arr = new ArrayList<>();
        for(long i : a){
            arr.add(i);
        }
        Collections.sort(arr);
        for(int i = 0; i < arr.size(); i++){
            a[i] = arr.get(i);
        }
        return a;
    }
    static int[] sort(int a[]){
        ArrayList<Integer> arr = new ArrayList<>();
        for(int i : a){
            arr.add(i);
        }
        Collections.sort(arr);
        // Collections.reverse(arr);
        for(int i = 0; i < arr.size(); i++){
            a[i] = arr.get(i);
        }
        return a;
    }
    
    
/* 
*/    
/*
1. Check overflow in pow function or in general
2. Check indices of read array function
3. Think of an easier solution because the problems you solve are always easy
4. Check iterator of loop
5. If still doesn't work, then jump from the 729th floor 'coz "beta tumse na ho paayega"

    Move to top!!
*/
    static class Foster {
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } 
                catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        int[] intArray(int n) {                   // Check indices
            int arr[] = new int[n];
            for(int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        long[] longArray(int n) {                 // Check indices
            long arr[] = new long[n];
            for(int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
        int[] getBits(int n) {                   //in Reverse Order
            int a[] = new int[31];
            for(int i = 0; i < 31; i++) {
                if(((1<<i) & n) != 0)
                    a[i] = 1;
            }
            return a;
        }
        static long pow(long... a) {
            long mod = Long.MAX_VALUE;
            if(a.length == 3)   mod = a[2];
            long res = 1;
            while(a[1] > 0) {
                if((a[1] & 1) == 1)
                    res = (res * a[0]) % mod;
                a[1] /= 2;
                a[0] = (a[0] * a[0]) % mod;
            }
            return res;
        }
    }
}
