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
#include <bits/stdc++.h>
using namespace std;
long long modularExponentiation(long long x, long long n, long long M) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return modularExponentiation((x * x) % M, n / 2, M);
  return (x * modularExponentiation((x * x) % M, (n - 1) / 2, M)) % M;
}
const long long N = 1000000;
long long n;
string s;
long long tree[2 * N];
long long seta(char c) {
  long long a = 0;
  long long f = c - 'a';
  a = 1 << f;
  return a;
}
void build(long long node, long long start, long long end) {
  if (start == end) {
    tree[node] = seta(s[start]);
  } else {
    long long mid = (start + end) / 2;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    tree[node] = tree[2 * node] | tree[2 * node + 1];
  }
}
void update(long long node, long long start, long long end, long long idx,
            char val) {
  if (start == end) {
    s[idx] = val;
    tree[node] = seta(val);
  } else {
    long long mid = (start + end) / 2;
    if (start <= idx and idx <= mid) {
      update(2 * node, start, mid, idx, val);
    } else {
      update(2 * node + 1, mid + 1, end, idx, val);
    }
    tree[node] = tree[2 * node] | tree[2 * node + 1];
  }
}
long long query(long long node, long long start, long long end, long long l,
                long long r) {
  if (r < start or end < l) {
    return 0;
  }
  if (l <= start and end <= r) {
    return tree[node];
  }
  long long mid = (start + end) / 2;
  long long p1 = query(2 * node, start, mid, l, r);
  long long p2 = query(2 * node + 1, mid + 1, end, l, r);
  return (p1 | p2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  n = s.size();
  build(1, 0, n - 1);
  long long q;
  cin >> q;
  while (q--) {
    long long x;
    cin >> x;
    if (x == 1) {
      long long y;
      char c;
      cin >> y >> c;
      update(1, 0, n - 1, y - 1, c);
    } else {
      long long y, z;
      cin >> y >> z;
      long long ans = query(1, 0, n - 1, y - 1, z - 1);
      long long co = 0;
      while (ans) {
        if (ans % 2 != 0) {
          co++;
        }
        ans /= 2;
      }
      cout << co << "\n";
    }
  }
}
