#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 1;
int t[4 * mx];
int power[28];
void build(string& s, int v, int tl, int tr) {
  if (tl == tr) {
    t[v] |= power[s[tl] - 'a'];
  } else {
    int tm = (tl + tr) / 2;
    build(s, v * 2, tl, tm);
    build(s, v * 2 + 1, tm + 1, tr);
    t[v] = t[v * 2] | t[v * 2 + 1];
  }
}
void query(int v, int tl, int tr, int l, int r, int& ans) {
  if (l > r) return;
  if (l == tl && r == tr) {
    ans |= t[v];
    return;
  }
  int tm = (tl + tr) / 2;
  query(v * 2, tl, tm, l, min(r, tm), ans);
  query(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, ans);
}
void update(int v, int tl, int tr, int pos, char new_val) {
  if (tl == tr) {
    t[v] = power[new_val - 'a'];
  } else {
    int tm = (tl + tr) / 2;
    if (pos <= tm)
      update(v * 2, tl, tm, pos, new_val);
    else
      update(v * 2 + 1, tm + 1, tr, pos, new_val);
    t[v] = t[v * 2] | t[v * 2 + 1];
  }
}
void solve() {
  int p = 1;
  for (int i = 0; i < 28; i++) power[i] = p, p *= 2;
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < mx; i++) t[i] = 0;
  build(s, 1, 0, n - 1);
  int q;
  cin >> q;
  int a, l, r;
  char c;
  while (q--) {
    cin >> a;
    if (a == 2) {
      cin >> l >> r;
      int k = 0;
      query(1, 0, n - 1, l - 1, r - 1, k);
      int ans = 0;
      for (int i = 0; i < 26; i++)
        if (power[i] & k) ans++;
      cout << ans << "\n";
    } else {
      cin >> l >> c;
      update(1, 0, n - 1, l - 1, c);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  ;
  long long t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
