#include <bits/stdc++.h>
using namespace std;
const int maxr = 10000000;
char rd[maxr], prt[maxr];
int rpos, ppos, mmx;
inline char readc() {
  if (!rpos) mmx = fread(rd, 1, maxr, stdin);
  char c = rd[rpos++];
  if (rpos == maxr) rpos = 0;
  if (rpos > mmx) return 0;
  return c;
}
template <typename T>
inline void read(T &x) {
  x = 0;
  register int flag = 1, c;
  while (((c = readc()) < '0' || c > '9') && c != '-')
    ;
  if (c == '-')
    flag = -1;
  else
    x = c - '0';
  while ((c = readc()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= flag;
}
inline int reads(char *s) {
  register int len = 0, c;
  while (isspace(c = readc()) || !c)
    ;
  s[len++] = c;
  while (!isspace(c = readc()) && c) s[len++] = c;
  s[len] = 0;
  return len;
}
inline void printc(char c) {
  prt[ppos++] = c;
  if (ppos == maxr) fwrite(prt, 1, ppos, stdout), ppos = 0;
}
inline void prints(char *s) {
  for (int i = 0; s[i]; i++) printc(s[i]);
}
template <typename T>
inline void print(T x, char c = '\n') {
  if (x < 0) printc('-'), x = -x;
  if (x) {
    static char sta[20];
    register int tp = 0;
    for (; x; x /= 10) sta[tp++] = x % 10 + '0';
    while (tp > 0) printc(sta[--tp]);
  } else
    printc('0');
  printc(c);
}
const int MAXN = 100005, B = 100;
int nxt[MAXN], n, m;
char str[MAXN], ttr[MAXN];
struct SAM {
  int son[205][26], par[205], cnt[205], len[205], buc[205], ord[205], tot, lst;
  void extend(int c) {
    int p = lst, np = ++tot;
    len[np] = len[p] + 1;
    for (; p && !son[p][c]; p = par[p]) son[p][c] = np;
    if (p > 0) {
      int q = son[p][c];
      if (len[q] != len[p] + 1) {
        int nq = ++tot;
        len[nq] = len[p] + 1;
        memcpy(son[nq], son[q], sizeof(son[nq]));
        par[nq] = par[q], par[q] = par[np] = nq;
        for (; son[p][c] == q; p = par[p]) son[p][c] = nq;
      } else
        par[np] = q;
    } else
      par[np] = 1;
    cnt[lst = np] = 1;
  }
  void build(char *s, int n) {
    memset(son, 0, sizeof(son));
    memset(par, 0, sizeof(par));
    memset(cnt, 0, sizeof(cnt));
    memset(len, 0, sizeof(len));
    memset(buc, 0, sizeof(buc));
    tot = lst = 1;
    for (int i = 0; i < n; i++) extend(s[i] - 'a');
    for (int i = 1; i <= tot; i++) ++buc[len[i]];
    for (int i = 1; i <= n; i++) buc[i] += buc[i - 1];
    for (int i = 1; i <= tot; i++) ord[buc[len[i]]--] = i;
    for (int i = tot; i > 1; i--) cnt[par[ord[i]]] += cnt[ord[i]];
  }
  int query(char *s, int n) {
    int k = 1;
    for (int i = 0; i < n && k; i++) k = son[k][s[i] - 'a'];
    return cnt[k];
  }
} sam[1005];
int main() {
  n = reads(str);
  for (int i = 0; i < n; i += B) {
    int j = min(n, i + B);
    sam[i / B].build(str + i, j - i);
  }
  read(m);
  while (m--) {
    int a, b, c;
    read(a), read(b);
    if (a == 1) {
      reads(ttr);
      str[--b] = ttr[0];
      b = b / B * B;
      sam[b / B].build(str + b, min(n, b + B) - b);
    } else {
      read(c);
      --b, --c;
      int l = reads(ttr), res = 0;
      nxt[0] = -1;
      for (int i = 1, j = 0; i < l; i++) {
        while (~j && ttr[j] != ttr[i]) j = nxt[j];
        nxt[i + 1] = ++j;
      }
      if (l > B || c / B - 1 <= b / B) {
        for (int i = b, j = 0; i <= c; i++) {
          while (~j && ttr[j] != str[i]) j = nxt[j];
          if (++j == l) ++res, j = nxt[j];
        }
      } else {
        int lb = b / B, rb = c / B;
        for (int i = b, j = 0; i < (lb + 1) * B + l - 1; i++) {
          while (~j && ttr[j] != str[i]) j = nxt[j];
          if (++j == l) ++res, j = nxt[j];
        }
        for (int i = rb * B - l + 1, j = 0; i <= c; i++) {
          while (~j && ttr[j] != str[i]) j = nxt[j];
          if (++j == l) ++res, j = nxt[j];
        }
        for (int i = lb + 1; i < rb; i++) res += sam[i].query(ttr, l);
        for (int t = lb + 2; t < rb; t++) {
          for (int i = t * B - l + 1, j = 0; i < t * B + l - 1; i++) {
            while (~j && ttr[j] != str[i]) j = nxt[j];
            if (++j == l) ++res, j = nxt[j];
          }
        }
      }
      print(res);
    }
  }
  fwrite(prt, 1, ppos, stdout);
  return 0;
}
