#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using i3 = pair<int, ii>;
using li = pair<ll, int>;
using lii = pair<ll, ii>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<ii>;
using vpll = vector<pll>;
using vi3 = vector<i3>;
using vlii = vector<lii>;
const int N = 1e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9, PI = acos(-1);
char s[N];
int n, q;
bool st[30][N << 2];
void update(int p1, int p2, int l, int r, int dx, bool val) {
  if (l == r) {
    st[p1][p2] = val;
    return;
  }
  int mid = (l + r) >> 1;
  if (dx <= mid)
    update(p1, p2 << 1, l, mid, dx, val);
  else
    update(p1, p2 << 1 | 1, mid + 1, r, dx, val);
  st[p1][p2] = st[p1][p2 << 1] | st[p1][p2 << 1 | 1];
}
bool query(int p1, int p2, int l, int r, int S, int E) {
  if (l >= S && r <= E) return st[p1][p2];
  if (l > E || r < S) return 0;
  int mid = (l + r) >> 1;
  return query(p1, p2 << 1, l, mid, S, E) |
         query(p1, p2 << 1 | 1, mid + 1, r, S, E);
}
void solve(int testCase) {
  scanf("%s %d", s + 1, &q);
  n = strlen(s + 1);
  for (int i = 1; s[i]; i++) {
    update(int(s[i] - 'a'), 1, 1, n, i, 1);
  }
  while (q--) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int dx;
      char c[2];
      scanf("%d %s", &dx, c);
      update(int(s[dx] - 'a'), 1, 1, n, dx, 0);
      update(int(c[0] - 'a'), 1, 1, n, dx, 1);
      s[dx] = c[0];
    } else {
      int l, r;
      scanf("%d %d", &l, &r);
      int ans = 0;
      for (int i = 0; i < 26; i++) {
        ans += int(query(i, 1, 1, n, l, r));
      }
      printf("%d\n", ans);
    }
  }
}
int main() {
  int t = 1;
  for (int testCase = 1; testCase <= t; testCase++) {
    solve(testCase);
  }
  return 0;
}
