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.*;
import java.math.BigInteger; 
import java.lang.*;




public class Main {
    
    
    static class sort1 implements Comparator<List<Integer>>
   {
        public int compare(List<Integer>  a,List<Integer> b)
        {
            
            return (a.size() - b.size());
        }
   }
    
   static class sort2p implements Comparator<int[]>
   {
        public int compare(int[] a,int[] b)
        {
            
            return -b[0]+a[0];
        }
   }
    static class sortP implements Comparator<int[]>
   {
        public int compare(int[] a,int[] b)
        {
            
            return -b[0]+a[0];
        }
   }
   static class sort implements Comparator<long[]>
   {
        public int compare(long[] a,long[] b)
        {
            
          return (int)(a[0]-b[0]);
        }
   }
  
   static class sort11 implements Comparator<double[]>
   {
        public int compare(double[] a,double[] b)
        {
            //if(a[0] == b[0]) return a[1]-b[1];
           if(a[1] < b[1]) return -1;
           else if(a[1] > b[1]) return 1;
           return 0;
        }
   }
   public static String[] F(BufferedReader bf) throws Exception
    {
        return (bf.readLine().split(" "));
    }
    
   public static void pr(PrintWriter out,Object o)
   {
      
    out.println(o.toString());//out.flush();
    
   }
   public static void prW(PrintWriter out,Object o)
   {
      
    out.print(o.toString());//out.flush();
    
   }
   public static int intIn(String st)
   {
      return Integer.parseInt(st);
   }
   
   
    
    public static void pr(Object o)
    {
        System.out.println(o.toString());
    }
    public static void prW(Object o)
    {
        System.out.print(o.toString());
    }
    
   
    public static int inInt(String s)
    {
        return Integer.parseInt(s);
    }
    public static long in(String s)
    {
        return Long.parseLong(s);
    }
 
 
    static int[] toIntArray(String[] m) 
    { 
        int[] p=new int[m.length];
        for(int o=0;o<m.length;o++)
        {
            p[o]= inInt(m[o]);
        }
        return p;
    }
    static double[] toDArray(String[] m) 
    { 
        double[] p=new double[m.length];
        for(int o=0;o<m.length;o=0)
        {
            p[o]= Double.parseDouble(m[o]);
        }
        return p;
    }
    static long[] toLArray(String[] m) 
    { 
       long[] p=new long[m.length];
        for(int o=0;o<m.length;o++)
        {
            p[o]= in(m[o]);
        }
        return p;
    }
   
     static long gcd(long a, long b)
        {
          if (b == 0)
            return a;
          return gcd(b, a % b); 
        }
     
        static long pow(long x, long y, long p)
      {
        if(y == 0) return 1l;
        long res = 1; // Initialize result
     
        x = x % p; // Update x if it is more than or
        // equal to p
     
        if (x == 0)
          return 0l; // In case x is divisible by p;
     
        while (y > 0)
        {
     
          // If y is odd, multiply x with result
          if ((y & 1) != 0)
            res = (res * x) % p;
     
          // y must be even now
          y = y >> 1; // y = y/2
          x = (x * x) % p;
        }
        return res;
      }
    
   
    

   
   

   
    static long __gcd(long n1, long n2)
    {

        if(n1==0l) return n2;
        if(n2==0l) return n1;
        if(n1==1l || n2==1l) return 1l;
       // long gcd = 1;
        if(n1 == n2)  return n1;
        if(n1>n2) return __gcd(n1%n2,n2);
        return __gcd(n1,n2%n1);
        
    }
    
   
    
    

    public static int F(int i,int last,Integer[][][] dp,int[] arr,int[][] dis,int len){
      int n = arr.length;
      if(i>=arr.length){
        if(len <= 1) return 2*arr.length;
        return 0;

      }

      if(dp[i][last][len] != null)  return dp[i][last][len];
      int res=arr.length;
      int p;
      if(last == n){

        res=Math.min(res,F(i+1,last,dp,arr,dis,len));
        if(len == 0) p=1;
        else p=2;

        res=Math.min(res,F(i+1,i,dp,arr,dis,p));

      }
      else{

        res=Math.min(res,F(i+1,last,dp,arr,dis,len));

        if(len == 0) p=1;
        else p=2;
        if(dis[arr[last]][i] == (i-last+1))
        res=Math.min(res,F(i+1,arr[i],dp,arr,dis,p));

      }

      dp[i][last][len] = res;return res;
 
    }
    public static long F(int i,int last,int c,Long[][][] dp,long[] size,long[] p){
      int n=size.length;
      if(i >= n){
          if(c < 3) return 1000000000000l;
          return 0;

      }
      if(c >= 3) return 0l; 
      if(dp[i][last][c] != null)  return dp[i][last][c];
      
      long re = F(i+1,last,c,dp,size,p);
      if(last == n || (size[last]<size[i]) ){ 
        if(c<3)
        re=Math.min(re,F(i+1,i,c+1,dp,size,p)+p[i]);
      }
      dp[i][last][c] = re;return re;

    }
    public static  boolean F(int i,int j,int p,Boolean[][][] dp,int[][] arr){
        if(i<0 || i>1 || j<0) return false;
        
        if(j >= arr[0].length){
          boolean ans = false;
          //System.out.println(i+" "+j);
          if(i == 1 && p == 0) ans =  true;

         return ans;
        }

        if(dp[i][j][p] != null)  return dp[i][j][p];
        boolean res=false;
        int v = arr[i][j];
        if(v == 0 || v==1){

           if(p == 0){
              res = F(i,j+1,0,dp,arr) || res;

           }
           // else if(p == 1){
           //  res = F(i,j-1,0,dp,arr) || res;
            
           // }
          //  else if(p == 2){
          //    res = F(i+1,j,2,dp,arr) || res;
            
          //  }
          // else if(p == 3){
          //      res = F(i-1,j,3,dp,arr) || res;            
          //  }

        }
        else{

          if(p == 0){
              res = F(i-1,j,3,dp,arr) || res;
              res = F(i+1,j,2,dp,arr) || res;

           }
           // else if(p == 1){
           //  res = F(i-1,j,2,dp,arr) || res;
           //    res = F(i+1,j,3,dp,arr) || res;
            
           // }
           else if(p == 2){
            // res = F(i,j-1,0,dp,arr) || res;
              res = F(i,j+1,0,dp,arr) || res;
            
           }
          else if(p == 3){
                //res = F(i,j-1,0,dp,arr) || res;
              res = F(i,j+1,0,dp,arr) || res;         
           }

        }

        dp[i][j][p] = res;return res;
    } 
    public static void main (String[] args) throws Exception {
        
        BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);;;//
        
        //int[] map=new int[1000001];
      
       int yy=1;//inInt(bf.readLine());
       


        
        
        
        for(int w=0;w<yy;w++)
        {
             //String str = bf.readLine();
          char[] arr = bf.readLine().toCharArray();
          out.flush();
         
            String[] xlp = bf.readLine().split(" ");
            
            //String st = bf.readLine();
          int n;//boolean bol=false;
          int  m;//long a,b,c;
           int k;
          // int l;
           //int double avg  k;//pr(out,"vbc");
       // boolean bol = false;
           //long mod=1000000000+7
       n=inInt(xlp[0]);//m=inInt(xlp[1]);//m=inInt(xlp[2]);//int j=in(xlp[3]);//long k=in(xlp[4]);
      TreeSet<Integer>[] pre = new TreeSet[26];

      for(int i=0;i<26;i++){
        pre[i] = new TreeSet<>();
      }
      for(int i=0;i<arr.length;i++){
        pre[arr[i]-'a'].add(i);
      }
      //pr(out,pre[0]+" "+pre[1]);
      for(int j=0;j<n;j++){
        xlp = bf.readLine().split(" ");
        if(xlp[0].charAt(0) == '1'){
          int index =Integer.parseInt(xlp[1])-1;
          char ch = xlp[2].charAt(0);
          int v = arr[index]-'a';
          pre[v].remove(index);
          pre[ch-'a'].add(index);
          arr[index] = ch;

        }
        else{
          int co=0;
          int index1 =Integer.parseInt(xlp[1])-1;int index2 =Integer.parseInt(xlp[2])-1;
          //pr(out,pre[0]);
          for(int i=0;i<26;i++){
            Integer vp1 = pre[i].floor(index2);
            if(vp1 == null) continue;
            Integer vp2 = pre[i].ceiling(index1);
            if(vp2 == null) continue;
            if(vp1 >= index1 && vp2<=index2){
              co++;
            }
            
          }

          pr(out,co);
 
        }

      }
       

           


       



       // for(int i=0;i<n;i++){
       //  for(int j=0;j<n;j++){
       //    pr(out,i+" "+j+" "+dis[i][j]);

       //  }
       // }




       

       



   }
    out.close();
   bf.close();//
       
}}


/*


Kickstart
 String rp;
            rp = "Case #"+(w+1)+": "+(n-ans)+" ";
static int[][] dir={{0,1},{1,0},{-1,0},{0,-1}};

static class SegmentTreeRMQ 
    { 
    int st[]; 
    int minVal(int x, int y) { 
        return (x > y) ? x : y; 
    } 
  
    
    int getMid(int s, int e) { 
        return s + (e - s) / 2; 
    } 
  
    
    int RMQUtil(int ss, int se, int qs, int qe, int index) 
    { 
        
        if (qs <= ss && qe >= se) 
            return st[index]; 
  
        // If segment of this node is outside the given range 
        if (se < qs || ss > qe) 
            return Integer.MIN_VALUE; 
  
        // If a part of this segment overlaps with the given range 
        int mid = getMid(ss, se); 
        return minVal(RMQUtil(ss, mid, qs, qe, 2 * index + 1), 
                RMQUtil(mid + 1, se, qs, qe, 2 * index + 2)); 
    } 
  
    // Return minimum of elements in range from index qs (query 
    // start) to qe (query end).  It mainly uses RMQUtil() 
    int RMQ(int n, int qs, int qe) 
    { 
        // Check for erroneous input values 
        
  
        return RMQUtil(0, n - 1, qs, qe, 0); 
    } 
  
    // A recursive function that constructs Segment Tree for 
    // array[ss..se]. si is index of current node in segment tree st 
    int constructSTUtil(int arr[], int ss, int se, int si) 
    { 
        // If there is one element in array, store it in current 
        //  node of segment tree and return 
        if (ss == se) { 
            st[si] = arr[ss]; 
            return arr[ss]; 
        } 
  
        // If there are more than one elements, then recur for left and 
        // right subtrees and store the minimum of two values in this node 
        int mid = getMid(ss, se); 
        st[si] = minVal(constructSTUtil(arr, ss, mid, si * 2 + 1), 
                constructSTUtil(arr, mid + 1, se, si * 2 + 2)); 
        return st[si]; 
    } 
  
    
    void con(int arr[]) 
    { 
        // Allocate memory for segment tree 
  
        //Height of segment tree 
        int n = (arr.length);
        int x = (int) (Math.ceil(Math.log(n) / Math.log(2))); 
  
        //Maximum size of segment tree 
        int max_size = 2 * (int) Math.pow(2, x) - 1; 
        st = new int[max_size]; // allocate memory 
  
        // Fill the allocated memory st 
        constructSTUtil(arr, 0, n - 1, 0); 
    }
    }
     static class DSU {
    
    int[] p;int[] sz;int op;int c;;
    int[] last;
    public void G(int n)
    {
        last=new int[n];
        p=new int[n];
        sz=new int[n];c=n;
        op=n;
        for(int h=0;h<n;h++)
        {
            sz[h]=1;p[h]=h;
            last[h]=h;
        }
    }
    public int find(int x)
    {
        int y=x;
        while(x!=p[x]) x=p[x];
        while(y!=p[y])
        {
            int tem=p[y];
            p[y]=x;y=tem;
        }
        return p[y];
    }
    public void union(int a,int b)
    {
        int x,y;
        x=find(a);y=find(b);
        if(x==y) return;
        if(sz[x]>sz[y])
        {
            p[y] = x;
            sz[x]+=sz[y];
            last[x]=Math.max(last[x],last[y]);
        }
        else
        {
            p[x]=y;sz[y]+=sz[x];
            last[y]=Math.max(last[y],last[x]);
        }
        c--;
        
    }}

    static long pow(long x, long y, long p)
      {
        long res = 1; // Initialize result
     
        x = x % p; // Update x if it is more than or
        // equal to p
     
        if (x == 0)
          return 0l; // In case x is divisible by p;
     
        while (y > 0)
        {
     
          // If y is odd, multiply x with result
          if ((y & 1) != 0)
            res = (res * x) % p;
     
          // y must be even now
          y = y >> 1; // y = y/2
          x = (x * x) % p;
        }
        return res;
      }
      static long gcd(long a, long b)
        {
          if (b == 0)
            return a;
          return gcd(b, a % b); 
        }
        static int gcd(int a, int b,int o)
        {
          if (b == 0)
            return a;
          return gcd(b, a % b,o); 
        }

Geometric median

public static double F(double[] x,double[] w)
    {
        double d1,d2;
        double S=0.00;
        for(double dp : w) S += dp;
        int k = 0;
        double sum = S - w[0]; // sum is the total weight of all `x[i] > x[k]`

        while(sum > S/2)
        {
            ++k;
            sum -= w[k];
        }
        d1=x[k];
        return d1;
        k = w.length-1;
       sum = S - w[k]; // sum is the total weight of all `x[i] > x[k]`

        while(sum > S/2)
        {
            --k;
            sum -= w[k];
        }
        d2=x[k];
        return new double[]{d1,d2};
    }
*/