#include <bits/stdc++.h>
const int N = 200005;
std::bitset<N> an, f[27];
int q, opt, l, r, pos;
char st[N], s[N], c;
int main() {
  scanf("%s", st + 1);
  int n = strlen(st + 1);
  for (int i = 1; i <= n; i++) f[st[i] - 'a'][i] = 1;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d", &opt);
    if (opt == 1) {
      scanf("%d %c", &pos, &c);
      f[st[pos] - 'a'][pos] = 0;
      f[c - 'a'][pos] = 1;
      st[pos] = c;
    } else {
      scanf("%d%d%s", &l, &r, s + 1);
      an.set();
      int len = strlen(s + 1);
      for (int j = 1; j <= len; j++) an &= f[s[j] - 'a'] >> (j - 1);
      int anl = (an >> l).count(), anr = (an >> (r - len + 2)).count();
      if (anl < anr) anl = anr;
      printf("%d\n", anl - anr);
    }
  }
  return 0;
}
