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

public class Main1 {
	static PrintWriter out = new PrintWriter(System.out);
	static FastReader input = new FastReader();

	int st[][];
	char a[];
	int n;
	int ans[];

	void combine(int[] s1, int[] s2, int dist[]) { for (int i = 0; i < 26; i++) { dist[i] = s1[i] + s2[i]; } }

	void build(int i, int l, int r) {
		if (l == r) {
			st[i][a[l] - 'a']++;
		} else {
			int im = i << 1;
			int m = (l + r) >> 1;

			build(im, l, m);
			build(im + 1, m + 1, r);

			combine(st[im], st[im + 1], st[i]);
		}
	}

	void update(int i, int l, int r, int indx, int c) {
		st[i][a[indx] - 'a']--;
		st[i][c - 'a']++;
		
		if (l == r) {
			return;
		}

		int im = i << 1;
		int m = (l + r) >> 1;
		if (indx >= l && indx <= m) {
			update(im, l, m, indx, c);
		} else {
			update(im + 1, m + 1, r, indx, c);
		}

	}

	void query(int i, int l, int r, int a, int b) {

		if (l > b || r < a)
			return;

		if (l >= a && r <= b) {

			for (int x = 0; x < 26; x++) { ans[x] += st[i][x]; }
		} else {
			int im = i << 1;
			int m = (l + r) >> 1;
			query(im, l, m, a, b);
			query(im + 1, m + 1, r, a, b);
		}
	}

	void main1() throws NumberFormatException, IOException {

		a = input.nextLine().toCharArray();
		st = new int[a.length * 4][26];
		int q = input.nextInt();
		n = a.length;
		build(1, 0, a.length - 1);

		// out.println(Arrays.toString(st[1]));
		while (q-- > 0) {
			int t = input.nextInt();
			if (t == 1) {
				int x = input.nextInt();
				char c = input.next().charAt(0);
				update(1, 0, n - 1, x - 1, c);
				a[x - 1] = c;

			} else {
				ans = new int[26];
				int l = input.nextInt();
				int r = input.nextInt();
				query(1, 0, n - 1, l - 1, r - 1);
				int sum = 0;
				for (int i : ans) { sum += i > 0 ? 1 : 0; }
				out.println(sum);
			}
		}

		out.flush();

	}

	public static void main(String args[]) throws NumberFormatException, IOException {
		Main1 inst = new Main1();
		inst.main1();
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			// try {
			// br = new BufferedReader(new FileReader(new File("hamming.in")));
			// } catch (FileNotFoundException e) {
			// e.printStackTrace();
			// }
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements()) { st = new StringTokenizer(br.readLine()); }
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(next()); }

		long nextLong() throws NumberFormatException, IOException { return Long.parseLong(next()); }

		double nextDouble() throws NumberFormatException, IOException { return Double.parseDouble(next()); }

		String nextLine() throws IOException {
			String str = "";
			str = br.readLine();
			return str;
		}

		boolean hasNext() throws IOException { return br.ready(); }
	}

	static class con {
		static int IINF = (int) 1e9;
		static int _IINF = (int) -1e9;
		static long LINF = (long) 1e15;
		static long _LINF = (long) -1e15;
		static double EPS = 1e-9;
	}

	static class Triple implements Comparable<Triple> {
		int x;
		int y;

		int z;

		Triple(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		@Override
		public int compareTo(Triple o) {
			if (x == o.x && y == o.y)
				return z - o.z;
			if (x == o.x)
				return y - o.y;
			return x - o.x;
		}

		@Override
		public String toString() { return "(" + x + ", " + y + ", " + z + ")"; }
	}

	static class Pair implements Comparable<Pair> {
		int x;
		int y;

		Pair(int x, int y) {
			this.x = x;
			this.y = y;

		}

		@Override
		public int compareTo(Pair o) {
			if (x == o.x)
				return (int) (y - o.y);
			return (int) (x - o.x);
		}

		@Override
		public String toString() {

			return "(" + x + ", " + y + ")";
		}

	}

	static void shuffle(int[] a) {
		for (int i = 0; i < a.length; i++) {
			int r = i + (int) (Math.random() * (a.length - i));
			int tmp = a[r];
			a[r] = a[i];
			a[i] = tmp;
		}
	}

	static void shuffle(long[] a) {
		for (int i = 0; i < a.length; i++) {
			int r = i + (int) (Math.random() * (a.length - i));
			long tmp = a[r];
			a[r] = a[i];
			a[i] = tmp;
		}
	}

	static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }

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

	static class DSU {

		int[] p, rank, setSize;
		int numSets;

		DSU(int n) {
			p = new int[n];
			rank = new int[n];
			setSize = new int[n];
			numSets = n;

			for (int i = 0; i < n; i++) {
				p[i] = i;
				setSize[i] = 1;
			}

		}

		int findSet(int n) { return p[n] = p[n] == n ? n : findSet(p[n]); }

		boolean isSameSet(int n, int m) { return findSet(n) == findSet(m); }

		void mergeSet(int n, int m) {

			if (!isSameSet(n, m)) {
				numSets--;
				int p1 = findSet(n);
				int p2 = findSet(m);

				if (rank[p1] > rank[p2]) {
					p[p2] = p1;
					setSize[p1] += setSize[p2];
				} else {
					p[p1] = p2;
					setSize[p2] += setSize[p1];
					if (rank[p1] == rank[p2])
						rank[p1]++;
				}
			}

		}

		int size() { return numSets; }

		int setSize(int n) { return setSize[findSet(n)]; }

	}

	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		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[1024];
			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;
		}

		// ddd
		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++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}

	static ArrayList<Integer>[] allocateArrayList(int n) {
		ArrayList<Integer> g[] = new ArrayList[n];
		for (int i = 0; i < n; i++) { g[i] = new ArrayList<>(); }
		return g;
	}
}