#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops", "O3")
template <typename T>
inline T pw(T a, long long n, T res = 1) {
  while (n) {
    if (n & 1) res *= a;
    a *= a;
    n >>= 1;
  }
  return res;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
const long long E = 1e6 + 777;
const long long inf = 1e18 + 777;
const long long N = 1e5 + 777;
string s;
bitset<44> t[N << 2];
void B(long long v, long long l, long long r) {
  if (l == r) {
    t[v][s[l] - 'a'] = 1;
    return;
  }
  long long m = l + r >> 1;
  B(v << 1, l, m);
  B(v << 1 | 1, m + 1, r);
  t[v] = t[v << 1] | t[v << 1 | 1];
}
bitset<44> empt;
bitset<44> G(long long l, long long r, long long v, long long tl,
             long long tr) {
  if (tr < tl || tr < l || tl > r) return empt;
  if (l <= tl && tr <= r) return t[v];
  long long tm = tl + tr >> 1;
  return G(l, r, v << 1, tl, tm) | G(l, r, v << 1 | 1, tm + 1, tr);
}
void U(long long pos, long long val, long long v, long long l, long long r) {
  if (l == r) {
    t[v][s[l] - 'a'] = false;
    s[l] = val;
    t[v][val - 'a'] = true;
    return;
  }
  long long m = l + r >> 1;
  if (pos <= m)
    U(pos, val, v << 1, l, m);
  else
    U(pos, val, v << 1 | 1, m + 1, r);
  t[v] = t[v << 1] | t[v << 1 | 1];
}
signed main() {
  auto solve = [&]() {
    cin >> s;
    s = '#' + s;
    B(1, 1, s.size() - 1);
    long long q;
    cin >> q;
    for (long long p, l, r; q--;) {
      cin >> p >> l;
      if (p == 2) {
        cin >> r;
        cout << G(l, r, 1, 1, s.size() - 1).count() << '\n';
      } else {
        char x;
        cin >> x;
        U(l, x, 1, 1, s.size() - 1);
      }
    }
  };
  ;
  solve();
}
