#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXLEN = 100000;
const int MAXQLEN = 10;
const int ALPH = 4;
const int MAXBIT = MAXLEN * MAXQLEN * ALPH;
char s[MAXLEN + 1];
int slen;
int nq;
char q[MAXQLEN + 1];
int qlen;
vector<int> idx[MAXLEN][4];
int nidx;
int bit[MAXBIT + 1];
int off[MAXQLEN + 1][MAXQLEN][4];
int conv(char c) {
  if (c == 'A') return 0;
  if (c == 'C') return 1;
  if (c == 'G') return 2;
  if (c == 'T') return 3;
  assert(false);
  return -1;
}
void bmod(int x, int by) {
  ++x;
  while (x <= nidx) {
    bit[x] += by;
    x += x & -x;
  }
}
int bget(int x) {
  ++x;
  int ret = 0;
  while (x > 0) {
    ret += bit[x];
    x -= x & -x;
  }
  return ret;
}
void run() {
  scanf("%s", s);
  slen = strlen(s);
  for (int i = (0); i < (slen); ++i)
    for (int c = (0); c < (4); ++c) idx[i][c].clear();
  nidx = 0;
  for (qlen = 1; qlen <= MAXQLEN; ++qlen)
    for (int o = (0); o < (qlen); ++o)
      for (int c = (0); c < (4); ++c) {
        off[qlen][o][c] = nidx;
        for (int i = o; i < slen; i += qlen) idx[i][c].push_back(nidx++);
      }
  memset(bit, 0, sizeof(bit));
  for (int i = (0); i < (slen); ++i) {
    char c = conv(s[i]);
    for (int j = (0); j < (((int)(idx[i][c]).size())); ++j)
      bmod(idx[i][c][j], +1);
  }
  scanf("%d", &nq);
  for (int qi = (0); qi < (nq); ++qi) {
    int kind;
    scanf("%d", &kind);
    if (kind == 1) {
      int pos;
      char ch;
      scanf("%d %c", &pos, &ch);
      --pos;
      int oc = conv(s[pos]), nc = conv(ch);
      for (int j = (0); j < (((int)(idx[pos][oc]).size())); ++j)
        bmod(idx[pos][oc][j], -1);
      s[pos] = ch;
      for (int j = (0); j < (((int)(idx[pos][nc]).size())); ++j)
        bmod(idx[pos][nc][j], +1);
    }
    if (kind == 2) {
      int l, r;
      scanf("%d%d%s", &l, &r, q);
      qlen = strlen(q);
      --l, --r;
      int ret = 0;
      for (int o = (0); o < (qlen); ++o) {
        int cl = (l - o + qlen - 1) / qlen, cr = r < o ? -1 : (r - o) / qlen,
            qidx = ((o - l) % qlen + qlen) % qlen, c = conv(q[qidx]);
        if (cl > cr) continue;
        ret += bget(off[qlen][o][c] + cr) - bget(off[qlen][o][c] + cl - 1);
      }
      printf("%d\n", ret);
    }
  }
}
int main() {
  run();
  return 0;
}
