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.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class distinct_character_queries {

	public static void main(String[] args) throws Exception {
		new distinct_character_queries().run();
	}
	
	public static class BITRU {
		public long[] bit1, bit2;
		public int length;
		public BITRU(int length) {
			length++;
			this.length = length;
			bit1 = new long[length];
			bit2 = new long[length];
		}
		long query(int index, int code) throws Exception {
			if (code == 1) {
				long sum = 0;
				while (index > 0) {
					sum += bit1[index];
					index -= index & -index;
				}
				return sum;
			}
			else if (code == 2) {
				long sum = 0;
				while (index > 0) {
					sum += bit2[index];
					index -= index & -index;
				}
				return sum;
			}
			else {
				throw new Exception();
			}
		}
		void update(int index, long value, int code) throws Exception {
			if (code == 1) {
				while (index < length) {
					bit1[index] += value;
					index += index & -index;
				}
			}
			else if (code == 2) {
				while (index < length) {
					bit2[index] += value;
					index += index & -index;
				}
			}
			else {
				throw new Exception();
			}
		}
		void updateRange(long value, int left, int right) throws Exception {
			update(left, value, 1);
			update(right + 1, -value, 1);
			update(left, value * (left - 1), 2);
			update(right + 1, -value * right, 2);
		}
		long sum(int index) throws Exception {
			return query(index, 1) * index - query(index, 2);
		}
		long sum(int left, int right) throws Exception {
			return sum(right) - sum(left - 1);
		}
	}

	public void run() throws Exception {
		FastIO file = new FastIO();
		BITRU[] bits = new BITRU[26];
		char[] c = file.next().toCharArray();
		int n = c.length + 1;
		for (int i = 0; i < 26; i++) {
			bits[i] = new BITRU(n);
		}
		for (int i = 0; i < c.length; i++) {
			bits[c[i] - 'a'].updateRange(1, i + 1, i + 1);
		}
		int q = file.nextInt();
		while (q-->0) {
			int t = file.nextInt();
			if (t == 1) {
				int pos = file.nextInt();
				char chan = file.next().charAt(0);
				bits[c[pos - 1] - 'a'].updateRange(-1, pos, pos);
				c[pos - 1] = chan;
				bits[c[pos - 1] - 'a'].updateRange(1, pos, pos);
			}
			else {
				int a = file.nextInt();
				int b = file.nextInt();
				int ans = 0;
				for (int i = 0; i < 26; i++) {
					ans += Integer.signum((int) bits[i].sum(a, b));
				}
				System.out.println(ans);
			}
		}
		file.out.flush();
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;
		PrintWriter out;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		}

		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;
		}

		void print(Object o) {
			out.print(o);
		}

		void println(Object o) {
			out.println(o);
		}

		void printf(String s, Object... o) {
			out.printf(s, o);
		}
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n % mod;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2, mod);
			return (temp * temp) % mod;
		} else {
			long temp = pow(n, (p - 1) / 2, mod);
			temp = (temp * temp) % mod;
			return (temp * n) % mod;

		}
	}

	public static long pow(long n, long p) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2);
			return (temp * temp);
		} else {
			long temp = pow(n, (p - 1) / 2);
			temp = (temp * temp);
			return (temp * n);

		}
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
}
