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
/*
TO LEARN
1-segment trees
2-euler tour
3-fenwick tree and interval tree
*/
            import java.util.*;
		    import java.math.*;
		    import java.io.*; 
		    import java.util.stream.Collectors;
 
		     public class A{
		     
		    static FastReader scan=new FastReader();
		     public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));

		    public static void main(String[] args)  throws Exception 
		    {
	
		    //scan=new FastReader("vs.txt");
		    //out = new PrintWriter("hps.out");
		 
		 /*
		 currently doing 
		 1-digit dp
		 2-ds like fenwick and interval tree

		 */

		    int tt=1;
//tt=scan.nextInt();
		  
	 outer:while(tt-->0)
		    {
		StringBuilder s=new StringBuilder(scan.next());
		int q=scan.nextInt();
		//System.out.println(q);
		TreeSet<Integer>set[]=new TreeSet[26];
		for(int i=0;i<26;i++)
			set[i]=new TreeSet();
		for(int i=0;i<s.length();i++)
			{
				set[s.charAt(i)-'a'].add(i);
			}
			for(int i=0;i<q;i++)
			{
				int t=scan.nextInt();
				if(t==2)
				{
					int res=0;
					//System.out.println("FUCK");
					int l=scan.nextInt()-1,r=scan.nextInt()-1;
					for(char c='a';c<='z';c++)
					{
						Integer higher=set[c-'a'].higher(l-1);
						if(higher==null)
							continue;
						if(higher<=r)
							res++;
					}
					out.println(res);
				}
				else {
					int pos=scan.nextInt()-1;
					String ch=scan.next();
					set[s.charAt(pos)-'a'].remove(pos);
					//System.out.println(pos);
					set[ch.charAt(0)-'a'].add(pos);
					s.setCharAt(pos,ch.charAt(0));
				}
			}

		 
 }
		  	    out.close();
		   
		}
		static class special{
			char x,y;
			//int id;
			special(char x,char y)
			{
				this.x=x;
				this.y=y;
				//this.id=id;
			}
			@Override
			    public int hashCode() {
		                return (int)(x + 31 * y);
		            }
		              @Override
		            public boolean equals(Object o){
		                if (o == this) return true;
		                if (o.getClass() != getClass()) return false;
		                special t = (special)o;
		                return t.x == x && t.y == y;
		            }
		}

		   
		     static long binexp(long a,long n)
		    {
		        if(n==0)
		            return 1;
		        long res=binexp(a,n/2);
		        if(n%2==1)
		            return res*res*a;
		        else 
		            return res*res;
		    }
		     
		    static long powMod(long base, long exp, long mod) {
		           if (base == 0 || base == 1) return base;
		           if (exp == 0) return 1;
		           if (exp == 1) return (base % mod+mod)%mod;
		           long R = (powMod(base, exp/2, mod) % mod+mod)%mod;
		           R *= R;
		           R %= mod;
		           if ((exp & 1) == 1) {
		               return (base * R % mod+mod)%mod;
		           }
		           else return (R %mod+mod)%mod;
		       }
		    static double dis(double x1,double y1,double x2,double y2)
		    {
		        return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		    }
		    static long mod(long x,long y)
		        {
		            if(x<0)
		                x=x+(-x/y+1)*y;
		            return x%y;
		        }
		     public static  long pow(long b, long e) {
		                long r = 1;
		                while (e > 0) {
		                    if (e % 2 == 1) r = r * b ;
		                    b = b * b;
		                    e >>= 1;
		                }
		                return r;
		            }
		    private static void sort(long[] arr) {
		            List<Long> list = new ArrayList<>();
		            for (long object : arr) list.add(object);
		            Collections.sort(list);
		        //Collections.reverse(list);
		            for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
		        }
		    private static void sort2(int[] arr) {
		            List<Integer> list = new ArrayList<>();
		            for (int object : arr) list.add(object);
		            Collections.sort(list);
		        Collections.reverse(list);
		            for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
		        }
		     public static class FastReader {
		            BufferedReader br;
		            StringTokenizer root;
		            
		     
		            public FastReader() {
		                br = new BufferedReader(new InputStreamReader(System.in));
		            }
		            FastReader(String filename)throws Exception
		            {
		     
		                br=new BufferedReader(new FileReader(filename));
		            }
		     
		            boolean hasNext(){
		                String line;
		                while(root.hasMoreTokens())
		                    return true;
		                return false;
		            }
		     
		            String next() {
		                while (root == null || !root.hasMoreTokens()) {
		                    try {
		                        root = new StringTokenizer(br.readLine());
		                    } catch (Exception addd) {
		                        addd.printStackTrace();
		                    }
		                }
		                return root.nextToken();
		            }
		     
		            int nextInt() {
		                return Integer.parseInt(next());
		            }
		     
		            double nextDouble() {
		                return Double.parseDouble(next());
		            }
		     
		            long nextLong() {
		                return Long.parseLong(next());
		            }
		     
		            String nextLine() {
		                String str = "";
		                try {
		                    str = br.readLine();
		                } catch (Exception addd) {
		                    addd.printStackTrace();
		                }
		                return str;
		            }
		             public int[] nextIntArray(int arraySize) {
		                int array[] = new int[arraySize];
		     
		                for (int i = 0; i < arraySize; i++) {
		                    array[i] = nextInt();
		                }
		     
		                return array;
		            }
		    }
		     static class Pair implements Comparable<Pair>{
		            public long x, y,z;
		            public Pair(long x1, long y1,long z1) {
		                x=x1;
		                y=y1;
		                z=z1;
		            }
		             public Pair(long x1, long y1) {
		                x=x1;
		                y=y1;
		    
		            }
		            
		            @Override
		            public int hashCode() {
		                return (int)(x + 31 * y);
		            }
		            public String toString() {
		                return x + " " + y+" "+z;
		            }
		            @Override
		            public boolean equals(Object o){
		                if (o == this) return true;
		                if (o.getClass() != getClass()) return false;
		                Pair t = (Pair)o;
		                return t.x == x && t.y == y&&t.z==z;
		            }
		    public int compareTo(Pair o)
		    {
		    	if(o.y>y)
		    		return 1;
		    	else if(o.y<y)
		    		return -1;
		    	else return 0;

		     
		        }
		     
		    }
		     static class tuple{
		            int x,y,z;
		            tuple(int a,int b,int c){
		                x=a;
		                y=b;
		                z=c;
		            }
		        }
		        static class Edge{
		            int d,w;
		            Edge(int d,int w)
		            {
		                this.d=d;
		                this.w=w;
		            }
		        }
		    }

		     
