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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.io.BufferedReader;

public class D {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskF solver = new TaskF();
		solver.solve(1, in, out);
		out.close();
	}

	static class SegmentTree {
		int st[][];
		int n;

		SegmentTree(char arr[], int n) {
			int x = (int) (Math.ceil(Math.log(n) / Math.log(2)));
			int max_size = 2 * (int) Math.pow(2, x) - 1;
			st = new int[max_size][26];
			this.n = n;
			constructSTUtil(arr, 0, n - 1, 0);
		}

		int getMid(int s, int e) {
			return s + (e - s) / 2;
		}

		int[] getSumUtil(int ss, int se, int qs, int qe, int si) {
			if (qs <= ss && qe >= se)
				return st[si];

			if (se < qs || ss > qe)
				return new int[26];

			int mid = getMid(ss, se);
			int c1 = 2 * si + 1;
			int c2 = 2 * si + 2;
			int[] m1 = getSumUtil(ss, mid, qs, qe, c1);
			int[] m2 = getSumUtil(mid + 1, se, qs, qe, c2);
			int[] m = new int[26];
			for (int i = 0; i < 26; i++) {
				m[i] = m1[i] + m2[i];
			}
			return m;
		}

		void updateValueUtil(int ss, int se, int i, char new_val, char old_val, int si) {
			if (i < ss || i > se)
				return;

			st[si][old_val - 'a']--;
			st[si][new_val - 'a']++;

			if (se != ss) {
				int mid = getMid(ss, se);
				updateValueUtil(ss, mid, i, new_val, old_val, 2 * si + 1);
				updateValueUtil(mid + 1, se, i, new_val, old_val, 2 * si + 2);
			}
		}

		void updateValue(char arr[], int n, int i, char new_val) {
			if (i < 0 || i > n - 1) {
				return;
			}
			char old_val = arr[i];
			arr[i] = new_val;
			updateValueUtil(0, n - 1, i, new_val, old_val, 0);
		}

		void constructSTUtil(char arr[], int ss, int se, int si) {
			if (ss == se) {
				st[si][arr[ss] - 'a'] = 1;
				return;
			}
			int mid = getMid(ss, se);
			int c1 = si * 2 + 1;
			int c2 = si * 2 + 2;
			constructSTUtil(arr, ss, mid, c1);
			constructSTUtil(arr, mid + 1, se, c2);
			for (int i = 0; i < 26; i++) {
				st[si][i] = st[c1][i] + st[c2][i];
			}
		}

	}

	static class TaskF {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			String s = in.next();
			int q = in.nextInt();
			char[] c = s.toCharArray();
			int n = c.length;
			SegmentTree t = new SegmentTree(c, n);
			while (q > 0) {
				int m = in.nextInt();
				if (m == 1) {
					int i = in.nextInt();
					i--;
					String k = in.next();
					char p = k.charAt(0);
					t.updateValue(c, n, i, p);
				} else {
					int i = in.nextInt();
					i--;
					int j = in.nextInt();
					j--;
					int[] h = t.getSumUtil(0, n - 1, i, j, 0);
					int ans = 0;
					for (int k = 0; k < 26; k++)
						if (h[k] > 0)
							ans++;
					out.println(ans);
				}
				q--;
			}
		}

	}

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

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

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

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