#include <bits/stdc++.h>
using namespace std;
struct node {
  long long int b[26];
};
string s;
node merge(node seg1, node seg2) {
  node temp;
  long long int i;
  for (i = 0; i < 26; i++) temp.b[i] = seg1.b[i] + seg2.b[i];
  return temp;
}
void build(node seg[], long long int pos, long long int l, long long int r) {
  if (l == r) {
    seg[pos].b[s[l] - 'a'] = 1;
    return;
  }
  long long int pos1 = 2 * pos + 1;
  long long int pos2 = pos1 + 1;
  long long int mid = (l + r) / 2;
  build(seg, pos1, l, mid);
  build(seg, pos2, mid + 1, r);
  seg[pos] = merge(seg[pos1], seg[pos2]);
  return;
}
node query(node seg[], long long int pos, long long int l, long long int r,
           long long int l1, long long int r1) {
  long long int mid = (l + r) / 2, i;
  if (l1 <= l && r1 >= r) return seg[pos];
  if (l1 > r || r1 < l) {
    node temp;
    for (i = 0; i < 26; i++) temp.b[i] = 0;
    return temp;
  }
  return merge(query(seg, 2 * pos + 1, l, mid, l1, r1),
               query(seg, 2 * pos + 2, mid + 1, r, l1, r1));
}
void update(node seg[], long long int pos, long long int l, long long int r,
            long long int x, char ele) {
  if (l > r) return;
  if (l > x || r < x) return;
  if (l == r) {
    seg[pos].b[s[x] - 'a']--;
    seg[pos].b[ele - 'a']++;
    return;
  }
  long long int mid = (l + r) / 2;
  long long int pos1 = 2 * pos + 1;
  long long int pos2 = 2 * pos + 2;
  update(seg, pos1, l, mid, x, ele);
  update(seg, pos2, mid + 1, r, x, ele);
  seg[pos] = merge(seg[pos1], seg[pos2]);
  return;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  long long int n = s.length(), i, j, q, t1, t2, t3;
  char c;
  node seg[4 * n + 7];
  for (i = 0; i < 4 * n + 7; i++)
    for (j = 0; j < 26; j++) seg[i].b[j] = 0;
  build(seg, 0, 0, n - 1);
  cin >> q;
  while (q--) {
    cin >> t1;
    if (t1 == 1) {
      cin >> t2 >> c;
      update(seg, 0, 0, n - 1, t2 - 1, c);
      s[t2 - 1] = c;
    } else {
      cin >> t2 >> t3;
      node temp = query(seg, 0, 0, n - 1, t2 - 1, t3 - 1);
      long long int ans = 0;
      for (i = 0; i < 26; i++)
        if (temp.b[i]) ans++;
      cout << ans << endl;
    }
  }
}

### Prompt

Construct a cpp code solution to the problem outlined:

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;
struct node {
  long long int b[26];
};
string s;
node merge(node seg1, node seg2) {
  node temp;
  long long int i;
  for (i = 0; i < 26; i++) temp.b[i] = seg1.b[i] + seg2.b[i];
  return temp;
}
void build(node seg[], long long int pos, long long int l, long long int r) {
  if (l == r) {
    seg[pos].b[s[l] - 'a'] = 1;
    return;
  }
  long long int pos1 = 2 * pos + 1;
  long long int pos2 = pos1 + 1;
  long long int mid = (l + r) / 2;
  build(seg, pos1, l, mid);
  build(seg, pos2, mid + 1, r);
  seg[pos] = merge(seg[pos1], seg[pos2]);
  return;
}
node query(node seg[], long long int pos, long long int l, long long int r,
           long long int l1, long long int r1) {
  long long int mid = (l + r) / 2, i;
  if (l1 <= l && r1 >= r) return seg[pos];
  if (l1 > r || r1 < l) {
    node temp;
    for (i = 0; i < 26; i++) temp.b[i] = 0;
    return temp;
  }
  return merge(query(seg, 2 * pos + 1, l, mid, l1, r1),
               query(seg, 2 * pos + 2, mid + 1, r, l1, r1));
}
void update(node seg[], long long int pos, long long int l, long long int r,
            long long int x, char ele) {
  if (l > r) return;
  if (l > x || r < x) return;
  if (l == r) {
    seg[pos].b[s[x] - 'a']--;
    seg[pos].b[ele - 'a']++;
    return;
  }
  long long int mid = (l + r) / 2;
  long long int pos1 = 2 * pos + 1;
  long long int pos2 = 2 * pos + 2;
  update(seg, pos1, l, mid, x, ele);
  update(seg, pos2, mid + 1, r, x, ele);
  seg[pos] = merge(seg[pos1], seg[pos2]);
  return;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  long long int n = s.length(), i, j, q, t1, t2, t3;
  char c;
  node seg[4 * n + 7];
  for (i = 0; i < 4 * n + 7; i++)
    for (j = 0; j < 26; j++) seg[i].b[j] = 0;
  build(seg, 0, 0, n - 1);
  cin >> q;
  while (q--) {
    cin >> t1;
    if (t1 == 1) {
      cin >> t2 >> c;
      update(seg, 0, 0, n - 1, t2 - 1, c);
      s[t2 - 1] = c;
    } else {
      cin >> t2 >> t3;
      node temp = query(seg, 0, 0, n - 1, t2 - 1, t3 - 1);
      long long int ans = 0;
      for (i = 0; i < 26; i++)
        if (temp.b[i]) ans++;
      cout << ans << endl;
    }
  }
}

```