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;
const int N = 100050;
const int S = 150;
const int M = S * 2 + 69;
struct SuffixTree {
  int go[M][27], link[M], leaf[M], dp[M], b[M], e[M], sz, cnt;
  vector<int> gone[M];
  string t;
  SuffixTree() {}
  void Init() {
    for (int i = 1; i <= cnt; i++) {
      for (int j = 0; j < gone[i].size(); j++) go[i][gone[i][j]] = 0;
      gone[i].clear();
    }
    sz = 0;
    cnt = 1;
  }
  int SZ(int u) { return leaf[u] ? sz - b[u] + 1 : e[u] - b[u] + 1; }
  void DFS(int c) {
    dp[c] = leaf[c];
    for (int i = 0; i < gone[c].size(); i++) {
      int j = gone[c][i];
      DFS(go[c][j]);
      dp[c] += dp[go[c][j]];
    }
  }
  void Build(string &s) {
    Init();
    t = s;
    t += ('a' + 26);
    int c = 1, k, len = 0, nxt = 0, work = 0, last = 0;
    link[1] = 1;
    cnt = 1;
    for (k = 0; k < t.size(); k++) {
      sz = k;
      work++;
      while (work) {
        if (!len) nxt = k;
        if (!go[c][t[nxt] - 'a']) {
          int lef = ++cnt;
          leaf[lef] = 1;
          link[lef] = 1;
          b[lef] = e[lef] = k;
          go[c][t[nxt] - 'a'] = lef;
          gone[c].push_back(t[nxt] - 'a');
          if (last) link[last] = c, last = 0;
        } else {
          int cld = go[c][t[nxt] - 'a'];
          if (len >= SZ(cld)) {
            nxt += SZ(cld);
            len -= SZ(cld);
            c = cld;
            continue;
          }
          if (t[b[cld] + len] == t[k]) {
            len++;
            if (last) link[last] = c, last = 0;
            break;
          }
          int nod = ++cnt;
          leaf[nod] = 0;
          link[nod] = 1;
          int lef = ++cnt;
          leaf[lef] = 1;
          link[lef] = 1;
          go[c][t[nxt] - 'a'] = nod;
          go[nod][t[k] - 'a'] = lef;
          gone[nod].push_back(t[k] - 'a');
          go[nod][t[b[cld] + len] - 'a'] = cld;
          gone[nod].push_back(t[b[cld] + len] - 'a');
          b[nod] = b[cld];
          e[nod] = b[cld] + len - 1;
          b[cld] += len;
          b[lef] = e[lef] = k;
          if (last) link[last] = nod;
          last = nod;
        }
        work--;
        if (c == 1 && len > 0)
          len--, nxt = k - work + 1;
        else if (c != 1)
          c = link[c];
      }
    }
    DFS(1);
  }
  int Count(string &s) {
    int c = 1, i, j;
    for (i = 0; i < s.size();) {
      if (!c) return 0;
      int nx = go[c][s[i] - 'a'];
      e[nx] = b[nx] + SZ(nx) - 1;
      for (j = b[nx]; j <= e[nx] && i < s.size(); j++, i++)
        if (t[j] != s[i]) return 0;
      c = nx;
    }
    return dp[c];
  }
} Block[M * 3];
char word[N];
string str;
int z[N * 2];
int min(int a, int b) { return a > b ? b : a; }
int max(int a, int b) { return a > b ? a : b; }
int BruteForce(int l, int r) {
  string tmp = str;
  tmp += '$';
  int i;
  for (i = l; i <= r; i++) tmp += word[i];
  int L = 0, R = 0;
  z[0] = 0;
  for (i = 1; i < tmp.size(); i++) {
    z[i] = 0;
    if (i < R) z[i] = min(z[i - l], r - i + 1);
    while (tmp[i + z[i]] == tmp[z[i]]) z[i]++;
    if (z[i] + i - 1 > r) r = z[i] + i - 1, l = i;
  }
  int ans = 0;
  for (i = 0; i < tmp.size(); i++) ans += (z[i] == str.size());
  return ans;
}
int main() {
  int n, q, i, j, t, p, l, r;
  char ch, taj;
  scanf("%s", word + 1);
  n = strlen(word + 1);
  string tmp;
  for (i = 0; i <= n; i += S) {
    tmp = "";
    for (j = max(1, i); j < min(n + 1, i + S); j++) tmp += word[j];
    Block[i / S].Build(tmp);
  }
  scanf("%i", &q);
  while (q--) {
    scanf("%i", &t);
    if (t == 1) {
      scanf("%i %c", &p, &ch);
      word[p] = ch;
      int B = p / S;
      tmp = "";
      for (i = max(1, B * S); i < min(n + 1, (B + 1) * S); i++) tmp += word[i];
      Block[i / S].Build(tmp);
    } else {
      scanf("%i %i", &l, &r);
      cin >> str;
      int sz = str.size(), L = l / S, R = r / S;
      if (sz > S || L == R)
        printf("%i\n", BruteForce(l, r));
      else {
        int ans = 0;
        ans += BruteForce(l, (L + 1) * S - 1);
        for (i = L + 1; i < R; i++) ans += Block[i].Count(str);
        ans += BruteForce(R * S, r);
        for (i = L + 1; i <= R; i++)
          ans += BruteForce(max(l, i * S - sz + 1), min(r, i * S + sz - 2));
        printf("%i\n", ans);
      }
    }
  }
  return 0;
}
