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.util.*;
import java.io.*;
public class dis{
	static int mod = (int)1e8;
	public static void main(String sp[])throws IOException{
		Scanner sc = new Scanner(System.in);
		String st = " "+sc.next();
		int n = st.length();	
		char arr[] = st.toCharArray();
		tree = new pair[4*n+1];
		for(int i=1;i<=4*n;i++){
			pair p = new pair();
			tree[i] = p;
		}
		build(arr, 1, n-1, 1);
		
		int q = sc.nextInt();
		while(q-->0){
			int flag=sc.nextInt();
			if(flag==1){
				int pos = sc.nextInt();
				char ch = sc.next().charAt(0);
				update(1, st.length()-1, pos, ch, arr[pos], 1);
				arr[pos]=ch;
			}else{
				
				int l = sc.nextInt();
				int r = sc.nextInt();
				int count=0;
				query(1, st.length()-1, l, r, 1);
				int arr1[] = new int[27];
				for(int i=0;i<ind.size();i++){
					for(int j=1;j<=26;j++){
						if(tree[ind.get(i)].freq[j]>=1)
							arr1[j]=1;
					}
				}
				for(int i=1;i<=26;i++){
					if(arr1[i]==1)
						count++;
				}
				System.out.println(count);
				ind  =new ArrayList<Integer>();
			}
		}
	}
	
	static pair tree[];
	static ArrayList<Integer> ind = new ArrayList<>();
	public static void query(int ss, int se, int l, int r, int index){
		
		if(ss>r || se<l)
			return ;
		
		if(ss>=l && se<=r){
			ind.add(index);
			return;
		}
		
		
		int mid = (ss+se)/2;
		query(ss, mid, l, r, 2*index);
		query(mid+1, se, l, r, 2*index+1);
	}
	
	
	public static void update(int ss, int se, int pos, char ch, char curr, int index){
		
		if(pos<ss || pos>se){
			return;
		}
		
		if(ss==se){
			for(int i=1;i<=26;i++){
			tree[index].freq[i] = 0;
			}			
			tree[index].freq[ch-'a'+1]+=1;
			return;
		}
		
		int mid = (ss+se)/2;
		update(ss, mid, pos, ch, curr, 2*index);
		update(mid+1, se, pos, ch, curr, 2*index+1);
		for(int i=1;i<=26;i++){
			tree[index].freq[i] = tree[2*index].freq[i]+tree[2*index+1].freq[i];
		}
		return;
	}
	
	public static void build(char arr[] , int ss, int se, int index){
		if(ss==se){
			tree[index].freq[arr[ss]-'a'+1]=1;
			return;
		}
		int mid = (ss+se)/2;
		build(arr, ss, mid, 2*index);
		build(arr, mid+1, se, 2*index+1);
		for(int i=1;i<=26;i++){
			tree[index].freq[i] = tree[2*index].freq[i]+tree[2*index+1].freq[i];
		}
		return;
	}
	
	
	
 
	public static class pair{
		int freq[] = new int[27];
	}
 
 
	static class Reader
	{
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;
		BufferedReader br;
		public Reader()
		{
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		public Reader(String file_name) throws IOException
		{
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}
 
		public String readLine() throws IOException
		{
			byte[] buf = new byte[64]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1)
			{
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}
		
		
		
 
		public int nextInt() throws IOException
		{
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do
			{
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
 
			if (neg)
				return -ret;
			return ret;
		}
 
		public long nextLong() throws IOException
		{
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do
			{
				ret = ret * 10 + c - '0';
			}
			while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}
 
		public double nextDouble() throws IOException
		{
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
 
			do
			{
				ret = ret * 10 + c - '0';
			}
			while ((c = read()) >= '0' && c <= '9');
 
			if (c == '.')
			{
				while ((c = read()) >= '0' && c <= '9')
				{
					ret += (c - '0') / (div *= 10);
				}
			}
 
			if (neg)
				return -ret;
			return ret;
		}
 
		private void fillBuffer() throws IOException
		{
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}
 
		private byte read() throws IOException
		{
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}
		StringTokenizer st;
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
 
		public void close() throws IOException
		{
			if (din == null)
				return;
			din.close();
		}
	}
}