#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
long long qpow(long long a, long long b, long long mod) {
  long long ret = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
  }
  return ret;
}
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= c == '-';
  for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  x = f ? -x : x;
}
const int N = 1e5 + 10;
const int M = 5e3 + 10;
const int mod = (int)1e9 + 7;
const double eps = 1e-10;
const double pi = acos(-1.0);
struct Node {
  bool c[26];
} a[N << 2];
int n;
int b[N];
char s[N];
void Up(int rt) {
  for (int i = 0; i < (26); i++)
    a[rt].c[i] = (a[rt << 1].c[i] | a[rt << 1 | 1].c[i]);
}
void build(int rt, int l, int r) {
  memset(a[rt].c, 0, sizeof(a[rt].c));
  if (l == r) {
    a[rt].c[b[l]] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  Up(rt);
}
void change(int rt, int l, int r, int x, int v, int old) {
  if (l == r) {
    a[rt].c[old] = 0;
    a[rt].c[v] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    change(rt << 1, l, mid, x, v, old);
  else
    change(rt << 1 | 1, mid + 1, r, x, v, old);
  Up(rt);
}
Node work(Node a, Node b) {
  for (int i = 0; i < (26); i++) a.c[i] |= b.c[i];
  return a;
}
int cal(Node a) {
  int cnt = 0;
  for (int i = 0; i < (26); i++)
    if (a.c[i]) cnt++;
  return cnt;
}
Node query(int rt, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    return a[rt];
  }
  Node ans;
  memset(ans.c, 0, sizeof(ans.c));
  int mid = (l + r) >> 1;
  if (L <= mid) ans = query(rt << 1, l, mid, L, R);
  if (mid < R) ans = work(ans, query(rt << 1 | 1, mid + 1, r, L, R));
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s + 1;
  n = strlen(s + 1);
  for (int i = 1; i <= (n); i++) {
    b[i] = s[i] - 'a';
  }
  build(1, 1, n);
  int q;
  int ty, x, y;
  char ss[5];
  cin >> q;
  while (q--) {
    cin >> ty >> x;
    if (ty == 1) {
      cin >> ss;
      change(1, 1, n, x, ss[0] - 'a', b[x]);
      b[x] = ss[0] - 'a';
    } else {
      cin >> y;
      Node ans = query(1, 1, n, x, y);
      printf("%d\n", cal(ans));
    }
  }
  return 0;
}

### Prompt

Your challenge is to write a Cpp solution to the following problem:

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
long long qpow(long long a, long long b, long long mod) {
  long long ret = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
  }
  return ret;
}
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= c == '-';
  for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  x = f ? -x : x;
}
const int N = 1e5 + 10;
const int M = 5e3 + 10;
const int mod = (int)1e9 + 7;
const double eps = 1e-10;
const double pi = acos(-1.0);
struct Node {
  bool c[26];
} a[N << 2];
int n;
int b[N];
char s[N];
void Up(int rt) {
  for (int i = 0; i < (26); i++)
    a[rt].c[i] = (a[rt << 1].c[i] | a[rt << 1 | 1].c[i]);
}
void build(int rt, int l, int r) {
  memset(a[rt].c, 0, sizeof(a[rt].c));
  if (l == r) {
    a[rt].c[b[l]] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  Up(rt);
}
void change(int rt, int l, int r, int x, int v, int old) {
  if (l == r) {
    a[rt].c[old] = 0;
    a[rt].c[v] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    change(rt << 1, l, mid, x, v, old);
  else
    change(rt << 1 | 1, mid + 1, r, x, v, old);
  Up(rt);
}
Node work(Node a, Node b) {
  for (int i = 0; i < (26); i++) a.c[i] |= b.c[i];
  return a;
}
int cal(Node a) {
  int cnt = 0;
  for (int i = 0; i < (26); i++)
    if (a.c[i]) cnt++;
  return cnt;
}
Node query(int rt, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    return a[rt];
  }
  Node ans;
  memset(ans.c, 0, sizeof(ans.c));
  int mid = (l + r) >> 1;
  if (L <= mid) ans = query(rt << 1, l, mid, L, R);
  if (mid < R) ans = work(ans, query(rt << 1 | 1, mid + 1, r, L, R));
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s + 1;
  n = strlen(s + 1);
  for (int i = 1; i <= (n); i++) {
    b[i] = s[i] - 'a';
  }
  build(1, 1, n);
  int q;
  int ty, x, y;
  char ss[5];
  cin >> q;
  while (q--) {
    cin >> ty >> x;
    if (ty == 1) {
      cin >> ss;
      change(1, 1, n, x, ss[0] - 'a', b[x]);
      b[x] = ss[0] - 'a';
    } else {
      cin >> y;
      Node ans = query(1, 1, n, x, y);
      printf("%d\n", cal(ans));
    }
  }
  return 0;
}

```