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;
const long long N = 1e5 + 5;
const int32_t maxn = N;
template <typename NODE, typename UPDATE>
struct segtree {
  bool built = false, lazy[4 * maxn];
  NODE zero = NODE(), t[4 * maxn];
  UPDATE noop = UPDATE(), upds[4 * maxn];
  int32_t tl[4 * maxn], tr[4 * maxn];
  inline void pushdown(int32_t v) {
    if (lazy[v]) {
      apply(v * 2, upds[v]);
      apply(v * 2 + 1, upds[v]);
      lazy[v] = 0;
      upds[v] = noop;
    }
  }
  inline void apply(int32_t v, UPDATE &val) {
    if (tl[v] != tr[v]) {
      lazy[v] = 1;
      upds[v].combine(val, tl[v], tr[v]);
    }
    val.apply(t[v], tl[v], tr[v]);
  }
  template <typename T>
  void build(T &a, int32_t v, int32_t l, int32_t r) {
    tl[v] = l;
    tr[v] = r;
    if (l == r) {
      t[v] = a[l];
      return;
    } else {
      int32_t tm = (l + r) / 2;
      build(a, v * 2, l, tm);
      build(a, v * 2 + 1, tm + 1, r);
      t[v].merge(t[v * 2], t[v * 2 + 1]);
    }
  }
  NODE query(int32_t v, long long l, long long r) {
    if (l > tr[v] || r < tl[v]) return zero;
    if (l <= tl[v] && tr[v] <= r) {
      return t[v];
    }
    pushdown(v);
    NODE a, b, ans;
    a = query(v * 2, l, r);
    b = query(v * 2 + 1, l, r);
    ans.merge(a, b);
    return ans;
  }
  void rupd(int32_t v, long long l, long long r, UPDATE &val) {
    if (l > tr[v] || r < tl[v]) return;
    if (l <= tl[v] && tr[v] <= r) {
      apply(v, val);
      return;
    }
    pushdown(v);
    rupd(v * 2, l, r, val);
    rupd(v * 2 + 1, l, r, val);
    t[v].merge(t[v * 2], t[v * 2 + 1]);
  }
  template <typename T>
  long long descent_right(long long l, T x, int32_t v, NODE &prev) {
    if (l > tr[v]) return len;
    if (l <= tl[v]) {
      NODE cur;
      cur.merge(prev, t[v]);
      if (!cur.check(x)) {
        swap(prev, cur);
        return len;
      }
      if (tl[v] == tr[v]) {
        return tr[v];
      }
    }
    pushdown(v);
    long long ans = descent_right(l, x, v * 2, prev);
    if (ans != len) return ans;
    return descent_right(l, x, v * 2 + 1, prev);
  }
  template <typename T>
  long long descent_left(long long r, T x, int32_t v, NODE &prev) {
    if (r < tl[v]) return -1;
    if (r >= tr[v]) {
      NODE cur;
      cur.merge(t[v], prev);
      if (!cur.check(x)) {
        swap(cur, prev);
        return -1;
      }
      if (tl[v] == tr[v]) {
        return tl[v];
      }
    }
    pushdown(v);
    long long ans = descent_left(r, x, v * 2 + 1, prev);
    if (ans != -1) return ans;
    return descent_left(r, x, v * 2, prev);
  }
  long long len = maxn;
  void clear() {
    fill(t, t + 4 * len, zero);
    fill(lazy, lazy + 4 * len, false);
    fill(upds, upds + 4 * len, noop);
    built = false;
  }
  template <typename T>
  void build(T &a) {
    build(a, 1, 0, len - 1);
    built = true;
  }
  template <typename T>
  long long descent_right(long long l, T x) {
    NODE prev = zero;
    return descent_right(l, x, 1, prev);
  }
  template <typename T>
  long long descent_left(long long r, T x) {
    NODE prev = zero;
    return descent_left(r, x, 1, prev);
  }
  NODE query(long long l, long long r) {
    if (!built) build(t);
    return query(1, l, r);
  }
  void rupd(long long l, long long r, UPDATE val) {
    if (!built) build(t);
    rupd(1, l, r, val);
  }
};
struct node1 {
  long long v = 0;
  node1() {}
  node1(long long val) { v = 1 << (val - 'a'); }
  void merge(node1 &l, node1 &r) { v = l.v | r.v; }
  bool check(long long x) { return false; }
};
struct update1 {
  long long v = 0;
  update1() {}
  update1(long long val) { v = val; }
  void combine(update1 &other, int32_t tl, int32_t tr) {}
  void apply(node1 &x, int32_t tl, int32_t tr) { x = node1(v); }
};
segtree<node1, update1> t;
char c[N];
void test_case() {
  long long q;
  cin >> c >> q;
  t.build(c);
  while (q--) {
    long long type;
    cin >> type;
    if (type == 1) {
      long long pos;
      char c;
      cin >> pos >> c;
      pos--;
      t.rupd(pos, pos, c);
    } else {
      long long l, r;
      cin >> l >> r;
      l--, r--;
      cout << __builtin_popcount(t.query(l, r).v) << "\n";
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  for (long long i = 0; i < t; i++) {
    test_case();
  }
  return 0;
}
