#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const unsigned long long ONE = (unsigned long long)1;
const double EPS = 1e-9;
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 2000 * 1000 * 1000;
const int MAXN = 100010;
template <typename T>
inline T sqr(T n) {
  return n * n;
}
unsigned long long mask_for(char c) {
  switch (c) {
    case 'A':
      return 0;
    case 'T':
      return 1;
    case 'G':
      return 2;
    case 'C':
      return 3;
  }
  return 100;
}
inline constexpr unsigned long long full(int len) { return (ONE << len) - ONE; }
inline unsigned long long rotate(unsigned long long mask, int len, int shift) {
  shift = len - shift;
  unsigned long long up = full(shift) << (len - shift);
  unsigned long long down = full(len) ^ up;
  return ((mask & up) >> (len - shift)) | ((mask & down) << shift);
}
unsigned long long populate(char* buf, int& mlen) {
  mlen = 0;
  int l = strlen(buf);
  unsigned long long res = 0;
  while (mlen + 2 * l < 64) {
    for (int i = 0; i < l; i++) {
      res |= mask_for(buf[i]) << mlen;
      mlen += 2;
    }
  }
  return res;
}
int n;
char s[MAXN];
unsigned long long mem[MAXN / 32 + 1000];
char cnt[1 << 16];
char buf[20];
int main() {
  cnt[0] = 0;
  for (int i = 1; i < (1 << 16); i++) {
    cnt[i] = cnt[i >> 2] + ((i & 3) == 3);
  }
  gets(s);
  n = strlen(s);
  for (int i = 0; i < n; i += 32) {
    for (int j = i; j < min(i + 32, n); j++) {
      mem[i >> 5] |= mask_for(s[j]) << ((j - i) * 2);
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int pos;
      char c;
      scanf("%d %c", &pos, &c);
      pos--;
      int idx = pos >> 5;
      int shift = (pos & full(5)) << 1;
      mem[idx] &= ~(3ull << shift);
      mem[idx] |= (mask_for(c) << shift);
    } else {
      int l, r;
      scanf("%d %d %s", &l, &r, buf);
      l--, r--;
      int mlen = 0;
      unsigned long long m = populate(buf, mlen);
      int ans = 0;
      auto single = [&](int l) {
        int idx = l >> 5;
        int shift = (l & full(5)) << 1;
        unsigned long long val = (mem[idx] >> shift) & 3ull;
        if (val == (m & 3)) {
          ans++;
        }
        m = rotate(m, mlen, 2);
      };
      while (l <= r && (l & full(5))) {
        single(l++);
      }
      int idxl = l >> 5;
      int idxr = r >> 5;
      while (idxl < idxr) {
        unsigned long long tmask = m | ((m & full(64 - mlen)) << mlen);
        m = rotate(m, mlen, 64 - mlen);
        unsigned long long xored = ~(tmask ^ mem[idxl++]);
        ans += cnt[xored & full(16)] + cnt[(xored >> 16) & full(16)] +
               cnt[(xored >> 32) & full(16)] + cnt[xored >> 48];
        l += 32;
      }
      while (l <= r) {
        single(l++);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
