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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
  
public class c720a
{
    //By shwetank_verma
	
   static int N=(int)1e5+5;
	 
	static int tree[][]=new int[30][4*N];
	 
	static void update(int node,int s,int e,int pos,int val,int x)
	{
	    if(s==e)
	    {
	        tree[x][node]=val;
	        return;
	    }
	 
	    int mid=(s+e)/2;
	 
	    if(s<=pos && pos<=mid)
	        update(2*node,s,mid,pos,val,x);
	    else
	        update(2*node+1,mid+1,e,pos,val,x);
	 
	    tree[x][node]=tree[x][2*node]+tree[x][2*node+1];
	}
	 
	static int query(int node,int s,int e,int l,int r,int x)
	{
	    if(r<s || l>e)
	        return 0;
	 
	    if(l<=s && e<=r)
	        return tree[x][node];
	 
	    int mid=(s+e)/2;
	    int p1=query(2*node,s,mid,l,r,x);
	    int p2=query(2*node+1,mid+1,e,l,r,x);
	 
	    return p1+p2;
	}
	public static void main(String[] args)
    {
        FastReader sc=new FastReader();
   
           
                int t=1;
                String str=sc.next();
                for(int i=0;i<100000;i++) {
                	for(int j=0;j<28;j++)
                		tree[j][i]=0;
                }
                char cc[]=str.toCharArray();
                int n=str.length();
                for(int i=0;i<str.length();i++) {
                	update(1,1,n,i+1,1,cc[i]-'a');
                }
   t=sc.nextInt();
              StringBuilder sb=new StringBuilder();
                while(t-->0){
                int v=sc.nextInt();
                
                if(v==1) {
                	int x=sc.nextInt();
                	char ch=sc.next().charAt(0);
                	
                	 --x;
                	 
                     update(1,1,n,x+1,0,cc[x]-'a');
                     cc[x]=ch;
                     update(1,1,n,x+1,1,ch-'a');
                }
                else {
                int l=sc.nextInt();
                
                int r=sc.nextInt();
                long ans=0;
                for(int i=0;i<26;++i) {
                  int vv=(query(1,1,n,l,r,i));
                  if(vv>0)
                	  ans++;
                
                }
                sb.append(ans);
                sb.append("\n");
                }
                
                }
                System.out.print(sb);
       
    }

static void ruffleSort(long[] a) {
		int n=a.length;
		Random r=new Random();
		for (int i=0; i<a.length; i++) {
			long oi=r.nextInt(n), temp=a[i];
			a[i]=a[(int)oi];
			a[(int)oi]=temp;
		}
		Arrays.sort(a);
	}
static void ruffleSort(int[] a) {
		int n=a.length;
		Random r=new Random();
		for (int i=0; i<a.length; i++) {
			int oi=r.nextInt(n), temp=a[i];
			a[i]=a[oi];
			a[oi]=temp;
		}
		Arrays.sort(a);
	}

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
  
        public FastReader()
        {
            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 int mod=1000000007;
    static boolean primes[]=new boolean[1000007];
    static ArrayList<Integer> b=new ArrayList<>();
    static boolean seive(int n){
        Arrays.fill(primes,true);
        primes[0]=primes[1]=false;
        for(int i=2;i*i<=n;i++){
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        }
        if(n<1000007){
        	for(int i=2;i<=n;i++) {
        		if(primes[i])
        			b.add(i);
        	}
            return primes[n];
        }
        return false;
        
    }
    static int gcd(int a,int b){
        if(b==0)
        return a;
        return gcd(b,a%b);
    }
    static long GCD(long a,long b){
        if(b==0)
        return a;
        return GCD(b,a%b);
    }
    static ArrayList<Integer> segseive(int l,int r){
    	
    	ArrayList<Integer> isprime=new ArrayList<Integer>();
    	boolean p[]=new boolean[r-l+1];
    	Arrays.fill(p, true);
        
    	for(int i=0;b.get(i)*b.get(i)<=r;i++) {
    		int currprime=b.get(i);
    		int base=(l/currprime)*currprime;
    		if(base<l) {
    			base+=currprime;
    		}
    		for(int j=base;j<=r;j+=currprime) {
    			p[j-l]=false;
    		}
    		
    		
    		if(base==currprime) {
    			p[base-l]=true;
    		}
    		
    	}
    	for(int i=0;i<=r-l;i++) {
    		if(p[i])
    			isprime.add(i+l);
    	}
    	return isprime;
    }
      static int LowerBound(int a[], int x) { // x is the target value or key
  int l=-1,r=a.length;
  while(l+1<r) {
    int m=(l+r)>>>1;
    if(a[m]>=x) r=m;
    else l=m;
  }
  return r;
}
static int UpperBound(int a[], int x) {// x is the key or target value
    int l=-1,r=a.length;
    while(l+1<r) {
       int m=(l+r)>>>1;
       if(a[m]<=x) l=m;
       else r=m;
    }
    return l+1;
 }

  
     
}
