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 double pi = 3.14159265358979;
const long long int mod = 1e9 + 7;
long long int takemod(long long int a, long long int mod) {
  return ((a % mod) + mod) % mod;
}
long long int power(long long int b, long long int p) {
  if (p == 0)
    return 1;
  else if (p % 2 == 0) {
    long long int q = power(b, p / 2);
    return ((q) * (q));
  } else
    return ((b) * (power(b, p - 1)));
}
long long int powerm(long long int b, long long int p) {
  if (p == 0)
    return 1;
  else if (p % 2 == 0) {
    long long int q = power(b, p / 2);
    return ((q % mod) * (q % mod)) % mod;
  } else
    return ((b % mod) * (power(b, p - 1) % mod)) % mod;
}
bool isprime(long long int n) {
  if (n == 1) return false;
  if (n == 2 or n == 3) return true;
  long long int lim = sqrt(n);
  long long int i = 2;
  while (i <= lim) {
    if (n % i == 0) return false;
    i++;
  }
  return true;
}
vector<long long int> factors(long long int n) {
  vector<long long int> a;
  a.push_back(1);
  long long int lim = sqrt(n), i = 2;
  while (i <= lim) {
    if (n % i == 0) {
      a.push_back(i);
      if (i != n / i) a.push_back(n / i);
    }
    i++;
  }
  if (n != 1) a.push_back(n);
  sort(a.begin(), a.end());
  return a;
}
vector<pair<long long int, long long int> > pf_with_count(long long int b) {
  pair<long long int, long long int> p;
  vector<pair<long long int, long long int> > pf;
  long long int count = 0;
  while (b % 2 == 0) {
    b /= 2;
    count++;
  }
  if (count > 0) {
    p.first = 2;
    p.second = count;
    pf.push_back(p);
  }
  long long int i = 3;
  while (i <= sqrt(b)) {
    count = 0;
    while (b % i == 0) {
      b /= i;
      count++;
    }
    if (count > 0) {
      p.first = i;
      p.second = count;
      pf.push_back(p);
    }
    i += 2;
  }
  if (b > 2) {
    p.first = b;
    p.second = 1;
    pf.push_back(p);
  }
  return pf;
}
long long int bs_t_i(string second) {
  long long int l = strtoull(second.c_str(), NULL, 2);
  return l;
}
string i_to_bs(long long int n) {
  string second = bitset<4>(n).to_string();
  return second;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string second;
  cin >> second;
  long long int i = 0;
  set<long long int> v[26];
  set<long long int>::iterator itr;
  while (i < second.size()) {
    v[second[i] - 'a'].insert(i + 1);
    i++;
  }
  long long int t;
  cin >> t;
  while (t--) {
    long long int x;
    cin >> x;
    if (x == 1) {
      long long int pos;
      cin >> pos;
      char c;
      cin >> c;
      long long int j = 0;
      if (v[second[pos - 1] - 'a'].size() > 0)
        itr = v[second[pos - 1] - 'a'].lower_bound(pos);
      if (v[second[pos - 1] - 'a'].size() > 0 and
          itr != v[second[pos - 1] - 'a'].end()) {
        v[second[pos - 1] - 'a'].erase(itr);
        v[c - 'a'].insert(*itr);
      }
      second[pos - 1] = c;
    } else {
      long long int l, r;
      cin >> l >> r;
      long long int j = 0;
      long long int count = 0;
      while (j < 26) {
        if (v[j].size() > 0) {
          itr = v[j].lower_bound(l);
          if (itr != v[j].end()) {
            if (*itr <= r) {
              count++;
            }
          }
        }
        j++;
      }
      cout << count << endl;
    }
  }
}
