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.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;
 
 
public class hello2
 {  
	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 String sum (String s)
    {
        String s1 = ""; 
        
        if(s.contains("a"))
            s1+="a";
        if(s.contains("e"))
            s1+="e";
        if(s.contains("i"))
            s1+="i";
        if(s.contains("o"))
            s1+="o";
        if(s.contains("u"))
            s1+="u";
        
            return s1;
            
        
    }
    
 
    public static HashMap<Integer, Integer> sortByValue(HashMap<Integer, Integer> hm) 
    { 
        // Create a list from elements of HashMap 
        List<Map.Entry<Integer, Integer> > list = 
               new LinkedList<Map.Entry<Integer, Integer> >(hm.entrySet()); 
  
        // Sort the list 
        Collections.sort(list, new Comparator<Map.Entry<Integer, Integer> >() { 
            public int compare(Map.Entry<Integer, Integer> o1,  
                               Map.Entry<Integer, Integer> o2) 
            { 
                return (o1.getValue()).compareTo(o2.getValue()); 
            } 
        }); 
          
        // put data from sorted list to hashmap  
        HashMap<Integer, Integer> temp = new LinkedHashMap<Integer, Integer>(); 
        for (Map.Entry<Integer, Integer> aa : list) { 
            temp.put(aa.getKey(), aa.getValue()); 
        } 
        return temp; 
    } 
    
 
public static void main(String args[])
    {
        FastReader input=new FastReader();
       
        String s = input.next();
        
        int q = input.nextInt();
        

        TreeSet<Integer> tr[]  = new TreeSet[26];
        
        for(int i=0;i<26;i++)
        {
        	tr[i] = new TreeSet();
        }
        
        for(int i=0;i<s.length();i++)
    	{
    		tr[s.charAt(i)-'a'].add(i+1);
    	}
        
        char c1[] = s.toCharArray();
        
        while(q-->0)
        {
        	int x = input.nextInt();
        	if(x==1)
        	{
        		int a = input.nextInt();
        		char b = input.next().charAt(0);
        		
        		
        		char c = c1[a-1];
        		
        		
        		tr[c-'a'].remove(a);
        		c1[a-1] = b;
        		tr[b-'a'].add(a);
        		
        		
        		
        		
        	}
        	else
        	{
        		int l = input.nextInt();
        		int r = input.nextInt();
        		int count =0;
        		for(int i=0;i<26;i++)
        		{
        			if(tr[i].ceiling(l)!=null)
        			{
        				if(tr[i].ceiling(l)<=r)
        				{
        					count++;
        				}
        			}
        		}
        		System.out.println(count);
        	}
        	
        
        }
        
        
    }
        
        
static int modFact(int n, 
        int p) 
{ 
if (n >= p) 
return 0; 

int result = 1; 
for (int i = 1; i <= n; i++) 
result = (result * i) % p; 

return result; 
}




static int binarySearch(long arr[], long x) 
{ 
    int l = 0, r = arr.length - 1; 
    while (l <= r) { 
        int m = l + (r - l) / 2; 

        // Check if x is present at mid 
        if (arr[m] == x) 
            return m; 

        // If x greater, ignore left half 
        if (arr[m] < x) 
            l = m + 1; 

        // If x is smaller, ignore right half 
        else
            r = m - 1; 
    } 

    // if we reach here, then element was 
    // not present 
    return -1; 
}
    

static long gcd(long a, long b) 
{ 
  if (b == 0) 
    return a; 
  return gcd(b, a % b);  
} 


public static void sort(int arr[])
{
    int n = arr.length;
    int count =0;
    // One by one move boundary of unsorted subarray
    for (int i = 0; i < n-1; i++)
    {
        // Find the minimum element in unsorted array
        int min_idx = i;
        for (int j = i+1; j < n; j++)
            if (arr[j] < arr[min_idx])
                min_idx = j;
 
        // Swap the found minimum element with the first
        // element
        if(min_idx!=i)
        {
        	int temp = arr[min_idx];
        
        arr[min_idx] = arr[i];
        arr[i] = temp;
        count++;
        }
        }
    System.out.println(count);
}


   
public static int even_element(int b[],int n)
{
	int c[] = new int[n/2 + 1];
	int l=0;
	for(int i=1;i<n;i+=2)
	{
		c[l] = b[i];
		
		System.out.print(c[l] + " ");
		l++;
	}
	System.out.println();
	if(c.length!=1)
	{
		return even_element(c,n/2);
	}
	else
		return c[0];
}
 
  
    
    static boolean isPrime(int n) 
    { 
        // Corner case 
        if (n <= 1) 
            return false; 
  
        // Check from 2 to n-1 
        for (int i = 2; i < n; i++) 
            if (n % i == 0) 
                return false; 
  
        return true; 
    } 
 }
 