abcdabcdab
5
2 2 8 ab
2 1 10 ab
1 3 a
1 4 b
2 1 4 ab

1
3
2

#include <bits/stdc++.h>
using namespace std;
int c[800], e[800];
struct sam_t {
  int g[800][26], f[800], l[800], w[800], nc;
  int gn(int len, int q = 0) {
    int p = nc++;
    l[p] = len;
    w[p] = 0;
    if (q)
      copy_n(g[q], 26, g[p]), f[p] = f[q];
    else
      fill_n(g[p], 26, 0), f[p] = 0;
    return p;
  }
  void clear() {
    nc = 0;
    gn(0);
    f[0] = -1;
  }
  void build(char* s, int n) {
    int p = 0;
    clear();
    for (int i = 0; i != n; ++i) {
      int o = s[i] - 'a', np = gn(l[p] + 1);
      w[np] = 1;
      for (; ~p && !g[p][o]; p = f[p]) g[p][o] = np;
      if (!~p)
        f[np] = 0;
      else {
        int q = g[p][o];
        if (l[p] + 1 == l[q])
          f[np] = q;
        else {
          int nq = gn(l[p] + 1);
          f[np] = f[q] = nq;
          for (; ~p && g[p][o] == q; p = f[p]) g[p][o] = nq;
        }
      }
      p = np;
    }
    fill_n(c, l[p] + 1, 0);
    for (int i = 1; i != nc; ++i) c[l[i]]++;
    for (int i = 1; i <= l[p]; ++i) c[i] += c[i - 1];
    for (int i = 1; i != nc; ++i) e[c[l[i]]--] = i;
    for (int i = nc - 1; i; --i) w[f[e[i]]] += w[e[i]];
  }
  int count(char* s, int n) {
    int p = 0;
    for (int i = 0; i != n; ++i) {
      int o = s[i] - 'a';
      p = g[p][o];
      if (!p) return 0;
    }
    return w[p];
  }
} sam[800];
int f[200001];
int kmp(char* s, int n, char* t, int m) {
  for (int i = 1, j = 0; i != n; ++i) {
    while (j && s[j] != s[i]) j = f[j - 1];
    if (s[i] == s[j]) ++j;
    f[i] = j;
  }
  int cnt = 0;
  for (int i = 0, j = 0; i != m; ++i) {
    while (j && t[i] != s[j]) j = f[j - 1];
    if (t[i] == s[j]) ++j;
    if (j == n) j = f[j - 1], cnt++;
  }
  return cnt;
}
char str[200001];
int m;
int bi[200001], bl[800], br[800], bs, bc;
void block_init() {
  bs = sqrt(m);
  bc = 1;
  bl[1] = 1;
  for (int i = 1; i <= m; ++i) {
    if (i - bl[bc] == bs) {
      br[bc++] = i;
      bl[bc] = i;
    }
    bi[i] = bc;
  }
  br[bc] = m + 1;
}
int main(void) {
  scanf("%s", str + 1);
  m = strlen(str + 1);
  block_init();
  for (int i = 1; i <= bc; ++i) sam[i].build(str + bl[i], br[i] - bl[i]);
  int q;
  scanf("%d", &q);
  while (q--) {
    int o;
    scanf("%d", &o);
    if (o == 1) {
      int i;
      char buf[20];
      scanf("%d%s", &i, buf);
      str[i] = buf[0];
      sam[bi[i]].build(str + bl[bi[i]], br[bi[i]] - bl[bi[i]]);
    } else {
      int l, r;
      static char s[200001];
      scanf("%d%d%s", &l, &r, s);
      int n = strlen(s), ans = 0;
      if (n >= bs || bi[l] == bi[r])
        ans = kmp(s, n, str + l, r - l + 1);
      else {
        for (int i = bi[l]; i < bi[r]; ++i) {
          int long long = max(br[i] - (n - 1), l),
                   rr = min(r + 1, br[i] + (n - 1));
          ans += kmp(s, n, str + long long, rr - long long);
          if (l <= bl[i] && (r + 1) >= br[i]) ans += sam[i].count(s, n);
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
