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 maxn = 500005;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const long long MOD = 100000007;
const double eps = 1e-10;
const double pi = 3.1415926535;
long long qpow(long long a, long long b) {
  long long tmp = a % MOD, ans = 1;
  while (b) {
    if (b & 1) {
      ans *= tmp, ans %= MOD;
    }
    tmp *= tmp, tmp %= MOD, b >>= 1;
  }
  return ans;
}
long long lowbit(long long x) { return x & -x; }
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
long long mmax(long long a, long long b, long long c) {
  return max(a, max(b, c));
}
long long mmin(long long a, long long b, long long c) {
  return min(a, min(b, c));
}
void mod(long long &a) {
  a += MOD;
  a %= MOD;
}
bool chk(long long now) {}
long long half(long long l, long long r) {
  while (l <= r) {
    long long m = (l + r) / 2;
    if (chk(m))
      r = m - 1;
    else
      l = m + 1;
  }
  return l;
}
long long ll(long long p) { return p << 1; }
long long rr(long long p) { return p << 1 | 1; }
long long mm(long long l, long long r) { return (l + r) / 2; }
long long lg(long long x) {
  if (x == 0) return 1;
  return (long long)log2(x) + 1;
}
bool smleql(double a, double b) {
  if (a < b || fabs(a - b) <= eps) return true;
  return false;
}
bool bigeql(double a, double b) {
  if (a > b || fabs(a - b) <= eps) return true;
  return false;
}
bool eql(double a, double b) {
  if (fabs(a - b) < eps) return 1;
  return 0;
}
double len(double a, double b, double c, double d) {
  return sqrt((a - c) * (a - c) + (b - d) * (b - d));
}
bool isp(long long x) {
  if (x == 1) return false;
  if (x == 2) return true;
  for (long long i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
inline long long read() {
  char ch = getchar();
  long long s = 0, w = 1;
  while (ch < 48 || ch > 57) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= 48 && ch <= 57) {
    s = (s << 1) + (s << 3) + ch - 48;
    ch = getchar();
  }
  return s * w;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (!(a & 1) && !(b & 1))
    return gcd(a >> 1, b >> 1) << 1;
  else if (!(b & 1))
    return gcd(a, b >> 1);
  else if (!(a & 1))
    return gcd(a >> 1, b);
  else
    return gcd(abs(a - b), min(a, b));
}
long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
char s[maxn];
long long n, q;
long long tr[maxn][27];
long long cnt[27];
void up(long long p) {
  for (long long i = 0; i < 26; ++i) tr[p][i] = tr[ll(p)][i] + tr[rr(p)][i];
}
void build(long long p, long long l, long long r) {
  if (l == r) {
    tr[p][s[l] - 'a']++;
    return;
  }
  long long m = mm(l, r);
  build(ll(p), l, m);
  build(rr(p), m + 1, r);
  up(p);
}
void modi(long long p, long long l, long long r, long long pos, long long val) {
  if (l == r && l == pos) {
    for (long long i = 0; i < 26; ++i) tr[p][i] = 0;
    tr[p][val] = 1;
    return;
  }
  long long m = mm(l, r);
  if (pos <= m)
    modi(ll(p), l, m, pos, val);
  else
    modi(rr(p), m + 1, r, pos, val);
  up(p);
}
void ask(long long p, long long l, long long r, long long L, long long R) {
  if (L <= l && r <= R) {
    for (long long i = 0; i < 26; ++i)
      if (tr[p][i] != 0) cnt[i]++;
    return;
  }
  long long m = mm(l, r);
  if (L <= m) ask(ll(p), l, m, L, R);
  if (R > m) ask(rr(p), m + 1, r, L, R);
}
signed main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  build(1, 1, n);
  q = read();
  while (q--) {
    long long op, x, y;
    char c[3];
    op = read();
    if (op == 2) {
      x = read(), y = read();
      for (long long i = 0; i < 26; ++i) cnt[i] = 0;
      ask(1, 1, n, x, y);
      long long ans = 0;
      for (long long i = 0; i < 26; ++i)
        if (cnt[i] != 0) ans++;
      write(ans), printf("\n");
    } else {
      x = read(), scanf("%s", c);
      modi(1, 1, n, x, c[0] - 'a');
    }
  }
  return 0;
}
