#include <bits/stdc++.h>
using namespace std;
string str;
int c[26][100005], len;
int read() {
  int A;
  bool K;
  char C;
  C = A = K = 0;
  while (C < '0' || C > '9') K |= C == '-', C = getchar();
  while (C > '/' && C < ':') A = (A << 3) + (A << 1) + (C ^ 48), C = getchar();
  return (K ? -A : A);
}
void write(int X) {
  if (X < 0) putchar('-'), X = -X;
  if (X > 9) write(X / 10);
  putchar(X % 10 + 48);
}
void add(int k, int x, int v) {
  while (x <= len) c[k][x] += v, x += (x & -x);
}
int sum(int k, int x) {
  int s = 0;
  while (x) s += c[k][x], x -= (x & -x);
  return s;
}
int main() {
  char ch;
  int i, op, x, y, q, rem;
  cin >> str;
  len = str.size();
  for (i = 1; i <= len; i++) add(str[i - 1] - 'a', i, 1);
  cin >> q;
  while (q--) {
    cin >> op >> x;
    if (op == 1) {
      add(str[x - 1] - 'a', x, -1);
      cin >> str[x - 1];
      add(str[x - 1] - 'a', x, 1);
    } else {
      rem = 0;
      cin >> y;
      for (i = 0; i <= 25; i++) rem += (sum(i, y) - sum(i, x - 1)) > 0;
      cout << rem << endl;
    }
  }
  return 0;
}
