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.io.StreamTokenizer;
import java.math.BigInteger;
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
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader sc = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, sc, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader sc, PrintWriter out) throws IOException {
        	char[] s=(" "+sc.next()).toCharArray();
        	int q=sc.nextInt();
        	SegTree sgt=new SegTree(s.length,s);
        	sgt.build(1, 1, s.length-1);
        	
        	while(q-->0) {
        		int opt=sc.nextInt();
        		if(opt==1) {
        			int index=sc.nextInt();
        			char c=sc.next().charAt(0);
        			sgt.change(1, index, c);
        		}
        		else {
        			int l=sc.nextInt();
        			int r=sc.nextInt();
        			boolean[] res=sgt.ask(1, l, r);
        			int ans=0;
        			for(int i=0;i<26;i++)
        				if(res[i])
        					++ans;
        			out.println(ans);
        		}
        	}
        } 

    }
    
    static class SegTree{
    	class Node{
    		int l;
    		int r;
    		char val;
    		boolean[] jud=new boolean[26];
    		
    		public Node(int l,int r) {
    			this.l=l;
    			this.r=r;
    		}
    	}
    	public Node[] t;
    	public char[] A;
    	
    	public SegTree(int n,char[] A) {
    		this.A=A;
    		this.t=new Node[(n+10)<<2];
    	}
    	
    	public void pushUp(int p) {
    		for(int i=0;i<26;i++) {
    			t[p].jud[i]=t[p*2].jud[i]||t[p*2+1].jud[i];
    		}
    	}
    	
    	public void build(int p,int l,int r) {
    		t[p]=new Node(l,r);
    		if(l==r) {
    			t[p].jud[A[l]-'a']=true;
    			t[p].val=A[l];
    			return ;
    		}
    		int mid=(l+r)>>1;
    		build(p*2,l,mid);
    		build(p*2+1,mid+1,r);
    		pushUp(p);
    	}
    	
    	public void change(int p,int index,char c) {
    		if(t[p].l==t[p].r) {
    			t[p].jud[t[p].val-'a']=false;
    			t[p].jud[c-'a']=true;
    			t[p].val=c;
    			return ;
    		}
    		int mid=(t[p].l+t[p].r)>>1;
    		if(index<=mid)
    			change(p*2,index,c);
    		else
    			change(p*2+1,index,c);
    		pushUp(p);
    	}
    	
    	public boolean[] ask(int p,int l,int r) {
    		if(t[p].l>=l&&t[p].r<=r)
    			return t[p].jud;
    		boolean[] res=new boolean[26];
    		int mid=(t[p].l+t[p].r)>>1;
    		if(l<=mid) {
    			boolean[] now=ask(p*2,l,r);
    			for(int i=0;i<26;i++)
    				if(now[i])
    					res[i]=true;
    		}
    		if(r>mid) {
    			boolean[] now=ask(p*2+1,l,r);
    			for(int i=0;i<26;i++)
    				if(now[i])
    					res[i]=true;
    		}
    		return res;
    	}
    }

    static class InputReader{
        StreamTokenizer tokenizer;
        public InputReader(InputStream stream){
            tokenizer=new StreamTokenizer(new BufferedReader(new InputStreamReader(stream)));
            tokenizer.ordinaryChars(33,126);
            tokenizer.wordChars(33,126);
        }
        public String next() throws IOException {
            tokenizer.nextToken();
            return tokenizer.sval;
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public boolean hasNext() throws IOException {
            int res=tokenizer.nextToken();
            tokenizer.pushBack();
            return res!=tokenizer.TT_EOF;
        }
        
        public double nextDouble() throws NumberFormatException, IOException {
        	return Double.parseDouble(next());
        }
        
        public BigInteger nextBigInteger() throws IOException {
        	return new BigInteger(next());
        }
    }
}
