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;
template <class T>
int check_mod(T a, T b) {
  return (a % b) ? 1 : 0;
}
template <class T>
void maxi(T &a, T b) {
  a = max(a, b);
  return;
}
template <class T>
void mini(T &a, T b) {
  a = min(a, b);
  return;
}
void sieve(vector<char> &prime, int range) {
  prime.resize(range + 1, 1);
  prime[0] = prime[1] = 0;
  for (int i = 2; i * i <= range; i++)
    if (prime[i])
      for (int j = (i << 1); j <= range; j += i) prime[j] = 0;
  return;
}
void sieve(vector<char> &prime, vector<int> &prime_list, int range) {
  prime.resize(range + 1, 1);
  prime[0] = prime[1] = 0;
  for (int i = 2; i * i <= range; i++)
    if (prime[i]) {
      prime_list.push_back(i);
      for (int j = (i << 1); j <= range; j += i) prime[j] = 0;
    }
  return;
}
void sieve(vector<char> &prime, vector<long long> &prime_list, int range) {
  prime.resize(range + 1, 1);
  prime[0] = prime[1] = 0;
  for (long long i = 2; i * i <= range; i++)
    if (prime[i]) {
      prime_list.push_back(i);
      for (long long j = (i << 1); j <= (long long)range; j += i) prime[j] = 0;
    }
  return;
}
bool is_letter(char a) {
  if (('a' <= a && a <= 'z') || ('A' <= a && a <= 'Z')) return true;
  return false;
}
bool is_vowel(char a) {
  string vowels = "aeiouyAEIOUY";
  for (char c : vowels)
    if (c == a) return true;
  return false;
}
bool is_valid(int i, int j, int N, int M) {
  return 0 <= i && i < N && 0 <= j && j < M;
}
bool all_adjacents_valid(int i, int j, int N, int M) {
  for (int di = -1; di <= 1; di++)
    for (int dj = -1; dj <= 1; dj++)
      if (((di) * (di)) + ((dj) * (dj)) == 1 && !is_valid(i + di, j + dj, N, M))
        return false;
  return true;
}
bool is_prime(int a) {
  if (a == 2) return true;
  if (!(a & 1) || a == 1) return false;
  for (int i = 3; i * i <= a; i += 2)
    if (!(a % i)) return false;
  return true;
}
bool is_prime(long long a) {
  if (a == 2) return true;
  if (!(a & 1) || a == 1) return false;
  for (long long i = 3; i * i <= a; i += 2)
    if (!(a % i)) return false;
  return true;
}
bool is_palindrome(string s) {
  int len = (int)s.length();
  int mid = len >> 1;
  for (int i = 0; i < mid; i++)
    if (s[i] != s[len - i - 1]) return false;
  return true;
}
bool is_palindrome(vector<char> s) {
  int len = (int)s.size();
  int mid = len >> 1;
  for (int i = 0; i < mid; i++)
    if (s[i] != s[len - i - 1]) return false;
  return true;
}
int gcd(int a, int b) {
  while (b) {
    int mod = a % b;
    a = b;
    b = mod;
  }
  return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int binpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
int binpow(int a, int b, int MODULO) {
  int res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= MODULO;
    }
    a *= a;
    a %= MODULO;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) {
  while (b) {
    long long mod = a % b;
    a = b;
    b = mod;
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
long long binpow(long long a, long long b, long long MODULO) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= MODULO;
    }
    a *= a;
    a %= MODULO;
    b >>= 1;
  }
  return res;
}
double distance(int X1, int Y1, int X2, int Y2) {
  return sqrt(((X1 - X2) * (X1 - X2)) + ((Y1 - Y2) * (Y1 - Y2)));
}
double distance(long long X1, long long Y1, long long X2, long long Y2) {
  return sqrt(((X1 - X2) * (X1 - X2)) + ((Y1 - Y2) * (Y1 - Y2)));
}
double distance(double X1, double Y1, double X2, double Y2) {
  return sqrt(((X1 - X2) * (X1 - X2)) + ((Y1 - Y2) * (Y1 - Y2)));
}
string binary(int N) {
  if (!N) return "0";
  string bin = "";
  while (N) {
    bin += '0' + (N & 1);
    N >>= 1;
  }
  reverse((bin).begin(), (bin).end());
  return bin;
}
string binary(long long N) {
  if (!N) return "0";
  string bin = "";
  while (N) {
    bin += '0' + (N & 1);
    N >>= 1;
  }
  reverse((bin).begin(), (bin).end());
  return bin;
}
vector<char> binary_v(int N) {
  if (!N) return {'0'};
  vector<char> bin;
  while (N) {
    bin.push_back('0' + (N & 1));
    N >>= 1;
  }
  reverse((bin).begin(), (bin).end());
  return bin;
}
vector<char> binary_v(long long N) {
  if (!N) return {'0'};
  vector<char> bin;
  while (N) {
    bin.push_back('0' + (N & 1));
    N >>= 1;
  }
  reverse((bin).begin(), (bin).end());
  return bin;
}
const int INF = 2147483547;
const int MODULO = 1000000007;
const int _MODULO = 998244353;
const long long INF64 = 9223372036854775707;
const long long MODULO64 = 1000000007;
const long long _MODULO64 = 998244353;
const double epsilon = 10e-6;
const double PI = acos(-1);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<set<int>> go(26);
  string s;
  cin >> s;
  int N = (int)s.length();
  for (int i = 0; i < N; ++i) go[s[i] - 'a'].insert(i);
  int qq;
  cin >> qq;
  while (qq--) {
    int type;
    cin >> type;
    if (type == 1) {
      int pos;
      char c;
      cin >> pos >> c;
      --pos;
      go[s[pos] - 'a'].erase(pos);
      s[pos] = c;
      go[s[pos] - 'a'].insert(pos);
      continue;
    }
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    int answer = 0;
    for (int c = 0; c < 26; ++c) {
      if (go[c].empty()) continue;
      auto it = go[c].lower_bound(l);
      if (it == go[c].end()) continue;
      answer += *it <= r;
    }
    cout << answer << '\n';
  }
  return 0;
}
