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.*;

/**
    @author KhanhNguyenn
 */
 
public class K{
    static int MAXN= 100010;
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        public void solve(InputReader in, PrintWriter out) {
            char[] s= in.nextToken().toCharArray();
            int q= in.nextInt();
            SEG seg= new SEG(s);
            while(q-->0){
                int c= in.nextInt();
                if(c==1){
                    int pos= in.nextInt()-1;
                    char ch= in.nextToken().charAt(0);
                    seg.update(1,pos,pos,ch);
                }
                else{
                    int l= in.nextInt()-1, r= in.nextInt()-1;
                    out.println(seg.count(l, r));
                    // int[] cnt= seg.count(l,r);
                    // for(int num:cnt){
                    //     out.print(num+" ");
                    // }
                    // out.println();
                }
            }
        }
    }

    static class SEG{
        static class Node{
            int[] cnt= new int[26];
            char setVal=' ';
            int left=-1, right=-1;
        }

        Node[] tree= new Node[4*MAXN];
        boolean[] lazy= new boolean[4*MAXN];
        char[] s;
        int n;

        public SEG(char[] s){
            this.s=s;
            this.n=s.length;
            build(1,0,n-1);
        }

        public void build(int i, int l, int r){
            tree[i]= new Node(); tree[i].left=l; tree[i].right=r;
            if(l==r){
                tree[i].cnt[s[l]-'a']++;
                tree[i].setVal=s[l];
            }
            else{
                int mid=(l+r)>>1;
                build(2*i,l,mid);
                build(2*i+1,mid+1,r);
                up(i);

            }
        }

        public void up(int i){
            Arrays.fill(tree[i].cnt,0);
            for(int j=0;j<26;j++){
                tree[i].cnt[j]+= tree[2*i].cnt[j]+tree[2*i+1].cnt[j];
            }
        }

        public void push(int i){
            if(lazy[i]){
                Arrays.fill(tree[i].cnt,0);
                tree[i].cnt[tree[i].setVal-'a']+=tree[i].right-tree[i].left+1;
                if(tree[i].left!=tree[i].right){
                    tree[2*i].setVal= tree[i].setVal;
                    tree[2*i+1].setVal= tree[i].setVal;
                    lazy[2*i]=true;
                    lazy[2*i+1]=true;
                }
                lazy[i]=false;
            }
        }

        public void update(int i, int l, int r, char ch){
            push(i);
            if(l>tree[i].right || r<tree[i].left) return;
            if(l<=tree[i].left && r>= tree[i].right){
                Arrays.fill(tree[i].cnt,0);
                tree[i].cnt[ch-'a']+= tree[i].right-tree[i].left+1;
                tree[i].setVal=ch;
                if(tree[i].left!=tree[i].right){
                    tree[2*i].setVal=ch;
                    tree[2*i+1].setVal=ch;
                    lazy[2*i]=true;
                    lazy[2*i+1]=true;
                }
                return;
            }
            update(2*i,l,r,ch);
            update(2*i+1,l,r,ch);
            up(i);
        }

        public int[] get(int i, int l, int r){
            int[] res= new int[26];
            push(i);
            if(l>tree[i].right || r<tree[i].left) return res;
            if(l<=tree[i].left && r>= tree[i].right){
                return tree[i].cnt;
            }
            int[] left= get(2*i,l,r); int[] right= get(2*i+1,l,r);
            for(int j=0;j<26;j++){
                res[j]+= left[j]+right[j];
            }
            return res;
        }

        public int count(int l, int r){
            int[] cnt= get(1,l,r);
            int res=0;
            for(int i=0;i<26;i++){
                if(cnt[i]>0) res++;
            }
            return res;
        }

    }

    static class Pair implements Comparable<Pair>{
        public int x, y;
        public Pair(int x, int y){
            this.x = x;
            this.y = y;
        }
 
        @Override
        public int compareTo(Pair o) {
            if (this.x > o.x){
                return 1;
            }
            else if (this.x < o.x){
                return -1;
            }
            else{
                return Integer.compare(this.y, o.y);
            }
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
 
        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }
 
        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public double nextDouble(){
            return Double.parseDouble(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}