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.util.*;
import java.lang.*;
import java.io.*;
 
public class Main
{
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
        	boolean env=System.getProperty("ONLINE_JUDGE") != null;
        	if(!env) {
        		try {
					br=new BufferedReader(new FileReader("src\\input.txt"));
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				}
        	}
        	else {
        		br = new BufferedReader(new
                        InputStreamReader(System.in)); 
        	}
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                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()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    static long MOD=1000000000+7;
    
    //Radix Sort
    public static int[] radixSort(int[] f){ return radixSort(f, f.length); }
    public static int[] radixSort(int[] f, int n)
    {
        int[] to = new int[n];
        {
            int[] b = new int[65537];
            for(int i = 0;i < n;i++)b[1+(f[i]&0xffff)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < n;i++)to[b[f[i]&0xffff]++] = f[i];
            int[] d = f; f = to;to = d;
        }
        {
            int[] b = new int[65537];
            for(int i = 0;i < n;i++)b[1+(f[i]>>>16)]++;
            for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
            for(int i = 0;i < n;i++)to[b[f[i]>>>16]++] = f[i];
            int[] d = f; f = to;to = d;
        }
        return f;
    }
    //Brian Kernighan’s Algorithm
    static long countSetBits(long n){
        if(n==0) return 0;
        return 1+countSetBits(n&(n-1));
    }
    //Euclidean Algorithm
    static long gcd(long A,long B){
        if(B==0) return A;
        return gcd(B,A%B);
    }
    //Modular Exponentiation
    static long fastExpo(long x,long n){
        if(n==0) return 1;
        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
    }
    //AKS Algorithm
    static boolean isPrime(long n){
        if(n<=1) return false;
        if(n<=3) return true;
        if(n%2==0 || n%3==0) return false;
        for(int i=5;i*i<=n;i+=6)
            if(n%i==0 || n%(i+2)==0) return false;
        return true;
    }
    //Sieve of eratosthenes
    static int[] findPrimes(int n){
        boolean isPrime[]=new boolean[n+1];
        ArrayList<Integer> a=new ArrayList<>();
        int result[];
        Arrays.fill(isPrime,true);
        isPrime[0]=false;
        isPrime[1]=false;
        for(int i=2;i*i<=n;++i){
            if(isPrime[i]==true){
                for(int j=i*i;j<=n;j+=i) isPrime[j]=false;
            }
        }
        for(int i=0;i<=n;i++) if(isPrime[i]==true) a.add(i);
        result=new int[a.size()];
        for(int i=0;i<a.size();i++) result[i]=a.get(i);
        return result;
        
    }
    //Lower Bound
    static int lowerBound(ArrayList<Long> a, int low, int high, long element){
        while(low < high){
            int middle = low + (high - low)/2;
            if(element > a.get(middle))
                low = middle + 1;
            else 
                high = middle;
        }
        return low;
    }
    //Upper Bound
    static int upperBound(Long a[], int low, int high, long element){
        while(low < high){
            int middle = low + (high - low)/2;
            if(a[middle] > element)
                high = middle;
            else 
                low = middle + 1;
        }
        return low;
    }
    static class node{
    	int count[];
    	node(){
    		count=new int[26];
    	}
    }
    static char s[];
    static node seg[];
    static void union(int root) {
    	node left=seg[2*root+1];
    	node right=seg[2*root+2];
    	seg[root]=new node();
    	for(int i=0;i<26;i++) seg[root].count[i]=left.count[i]+right.count[i];
    }
    static void build(int root,int l,int r) {
    	if(l==r) {
    		seg[root]=new node();
    		seg[root].count[s[l]-'a']++;
    		return;
    	}
    	int mid=(l+r)/2;
    	build(2*root+1,l,mid);
    	build(2*root+2,mid+1,r);
    	union(root);
    }
    static void update(int root,int l,int r,int idx,char c) {
    	if(l==r) {
    		seg[root].count[s[idx]-'a']--;
    		s[idx]=c;
    		seg[root].count[s[idx]-'a']++;
    		return;
    	}
    	int mid=(l+r)/2;
    	if(idx<=mid) update(2*root+1,l,mid,idx,c);
    	else update(2*root+2,mid+1,r,idx,c);
    	union(root);
    }
    static node query(int root,int l,int r,int x,int y) {
    	if(y<l || r<x) {
    		node ans=new node();
    		return ans;
    	}
    	if(x<=l && r<=y) return seg[root];
    	int mid=(l+r)/2;
    	node a=query(2*root+1,l,mid,x,y);
    	node b=query(2*root+2,mid+1,r,x,y);
    	node ans=new node();
    	for(int i=0;i<26;i++) ans.count[i]=a.count[i]+b.count[i];
    	return ans;
    }
    public static void main (String[] args) throws java.lang.Exception
    {
        FastReader sc=new FastReader();
        int test=1;
        while(test-->0) { 
        	s=sc.nextLine().toCharArray();
        	int n=s.length;
        	seg=new node[4*n];
        	build(0,0,n-1);
        	int q=sc.nextInt();
        	StringBuilder sb=new StringBuilder();
////        	System.out.println(Arrays.toString(seg[0].count));
//        	update(0,0,n-1,3,'b');
//        	update(0,0,n-1,4,'b');
////        	System.out.println(Arrays.toString(seg[0].count));
//        	node X=query(0,0,n-1,0,6);
//        	System.out.println(Arrays.toString(X.count));
        	while(q-->0) {
        		int type=sc.nextInt();
        		if(type==1) {
        			int idx=sc.nextInt()-1;
        			char c=sc.next().charAt(0);
        			update(0,0,n-1,idx,c);
        		}
        		else {
        			int x=sc.nextInt()-1,y=sc.nextInt()-1;
        			node result=query(0,0,n-1,x,y);
        			int ans=0;
        			for(int i=0;i<26;i++) if(result.count[i]>0) ans++;
        			sb.append(ans+"\n");
        		}
        	}
        	System.out.print(sb);
        }
    }
}