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

/**
 *
 * @author Saju
 *
 */




public class Main {

    private static int dx[] = { 1, 0, -1, 0 };
    private static int dy[] = { 0, -1, 0, 1 };
    
    private static int dx1[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
    private static int dy1[] = { 0, -1, -1, -1, 0, 1, 1, 1 };

    private static final long INF = (long) Math.pow(10, 16);
    private static final int INT_INF = Integer.MAX_VALUE;
    private static final long NEG_INF = Long.MIN_VALUE;
    private static final int NEG_INT_INF = Integer.MIN_VALUE;
    private static final double EPSILON = 1e-10;

    private static final long MAX = (long) 1e12;
    
    private static final long MOD = 1000000007;

    private static final int MAXN = 200001;
    private static final int MAXA = 1000004;
    private static final int MAXLOG = 22;
    private static final double PI = Math.acos(-1);
    
    public static void main(String[] args) throws IOException {

        InputReader in = new InputReader(System.in);
//        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

//         InputReader in = new InputReader(new FileInputStream("src/test.in"));
//         PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("src/test.out")));

        
        
/*



*/        
        
//        TreeSet<Long> list = new TreeSet<>();
//        list.add(2L);
//        list.add(2L);
//        list.add(3L);
//        list.add(5L);
//        list.add(5L);
//        
//        System.out.println(list.floor(1L));
//        
        
        String str = in.next();
        StringBuilder sb = new StringBuilder(str);
        TreeSet<Integer>[] set = new TreeSet[26];
        for(int i = 0; i < 26; i++) {
        	set[i] = new TreeSet<>();
        }
        int n = str.length();
        for(int i = 0; i < n; i++) {
        	int c = str.charAt(i) - 'a';
        	set[c].add(i);
        }
        
        int q = in.nextInt();
        for(int i = 0; i < q; i++) {
        	int a = in.nextInt();
        	if(a == 1) {
        		int p = in.nextInt() - 1;
        		char ch = in.next().charAt(0);
        		int v = ch - 'a';
        		int prev = sb.charAt(p) - 'a';
        		set[prev].remove(Integer.valueOf(p));
        		set[v].add(p);
        		sb.setCharAt(p, ch);
        	}
        	else {
        		int l = in.nextInt() - 1;
        		int r = in.nextInt() - 1;
        		int cnt = 0;
        		for(int j = 0; j < 26; j++) {
        			if(set[j].size() == 0) {
        				continue;
        			}
        			int ri = -1;
        			try {
        				ri = set[j].floor(r);
        			}
        			catch(Exception e) {
        				ri = -1;
        			}
        			
        			if(ri >= l && ri <= r) {
        				cnt++;
        			}
        			
        		}
        		out.println(cnt);
        		
        	}
        }
      
        
        in.close();
        out.flush();
        out.close();
        System.exit(0);
    }



	/*
     * return the number of elements in list that are less than or equal to the val
     */
    private static long upperBound(List<Long> list, long val) {
        int start = 0;
        int len = list.size();
        int end = len - 1;
        int mid = 0;

        while (true) {
            if (start > end) {
                break;
            }
            mid = (start + end) >> 1;
            long v = list.get(mid);
            if (v == val) {
                start = mid;
                while(start < end) {
                    mid = (start + end) >> 1;
                    if(list.get(mid) == val) {
                        if(mid + 1 < len && list.get(mid + 1) == val) {
                            start = mid + 1;
                        }
                        else {
                            return mid + 1;
                        }
                    }
                    else {
                        end = mid - 1;
                    }
                }
                return start + 1;
            }
            if (v > val) {
                end = mid - 1;
            } else {
                start = mid + 1;
            }
        }
        if (list.get(mid) < val) {
            return mid + 1;
        }
        return mid;
    }


    private static boolean isPalindrome(String str) {
        StringBuilder sb = new StringBuilder();
        sb.append(str);
        String str1 = sb.reverse().toString();
        return str.equals(str1);
    }

    private static String getBinaryStr(long n, int j) {
        String str = Long.toBinaryString(n);
        int k = str.length();
        for (int i = 1; i <= j - k; i++) {
            str = "0" + str;
        }

        return str;
    }
    
    private static long modInverse(long r) {
        return bigMod(r, MOD - 2, MOD);
    }
    
    private static long bigMod(long n, long k, long m) {

        long ans = 1;
        while (k > 0) {
            if ((k & 1) == 1) {
                ans = (ans * n) % m;
            }
            n = (n * n) % m;
            k >>= 1;
        }
        return ans;
    }
    
    private static long ceil(long n, long x) {
        long div = n / x;
        if(div * x != n) {
            div++;
        }
        return div;
    }
    
    private static int ceil(int n, int x) {
        int div = n / x;
        if(div * x != n) {
            div++;
        }
        return div;
    }

    
    private static int abs(int x) {
        if (x < 0) {
            return -x;
        }
        return x;
    }
    
    private static double abs(double x) {
        if (x < 0) {
            return -x;
        }
        return x;
    }

    private static long abs(long x) {
        if(x < 0) {
            return -x;
        }
        return x;
    }
    
    private static long lcm(long a, long b) {
        return (a * b) / gcd(a, b);
    }

    private static int lcm(int a, int b) {
        return (a * b) / gcd(a, b);
    }

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

    private static int log(long x, int base) {
        return (int) (Math.log(x) / Math.log(base));
    }

    private static int log(long x, long base) {
        return (int) (Math.log(x) / Math.log(base));
    }
    
    private static long min(long a, long b) {
        if (a < b) {
            return a;
        }
        return b;
    }

    private static int min(int a, int b) {
        if (a < b) {
            return a;
        }
        return b;
    }

    private static long max(long a, long b) {
        if (a < b) {
            return b;
        }
        return a;
    }

    private static int max(int a, int b) {
        if (a < b) {
            return b;
        }
        return a;
    }

    private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public List<Integer> nextList(int n) {
            List<Integer> list = new ArrayList<>();
            for(int i = 0; i < n; i++) {
                list.add(nextInt());
            }
            return list;
        }
        
        public List<Long> nextLongList(int n) {
            List<Long> list = new ArrayList<>();
            for(int i = 0; i < n; i++) {
                list.add(nextLong());
            }
            return list;
        }

        public String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());

                }
            } catch (IOException e) {
                return null;
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            String line = null;
            try {
                tokenizer = null;
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public boolean hasNext() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        
        public int[] nextIntArr(int n) {
            int arr[] = new int[n];
            for(int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        
        public long[] nextLongArr(int n) {
            long arr[] = new long[n];
            for(int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
        
        public int[] nextIntArr1(int n) {
            int arr[] = new int[n + 1];
            for(int i = 1; i <= n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        
        public long[] nextLongArr1(int n) {
            long arr[] = new long[n + 1];
            for(int i = 1; i <= n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
       
        public void close() {
            try {
                if(reader != null) {
                    reader.close();
                }
            }
            catch(Exception e) {
                
            }
            
            
        }
    }

}

		  	 		 	   	  	 	  		 	     	