#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, ans, b[100], a[4][11][10][N];
char s[N];
template <class T>
inline void in(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9';) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  for (; ch >= '0' && ch <= '9';) x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
inline void add(int i, int pos, int ty, int v) {
  for (; i < N; i += i & -i)
    for (int k = 1; k <= 10; ++k) a[ty][k][pos % k][i] += v;
}
inline int sum(int o, int pos, int ty, int len) {
  int ret = 0;
  for (; o; o -= o & -o) ret += a[ty][len][pos][o];
  return ret;
}
inline int query(int l, int r, int pos, int ty, int len) {
  return sum(r, pos, ty, len) - sum(l - 1, pos, ty, len);
}
int main() {
  scanf("%s", s), n = strlen(s);
  b['A'] = 0, b['G'] = 1, b['C'] = 2, b['T'] = 3;
  for (int i = 0; i < n; ++i) add(i + 1, i, b[s[i]], 1);
  char ch[51];
  int Q, op, l, r, p, len;
  for (in(Q); Q--;) {
    in(op);
    if (op & 1) {
      in(p), scanf("%s", ch);
      add(p, p - 1, b[s[p - 1]], -1);
      add(p, p - 1, b[ch[0]], 1);
      s[p - 1] = ch[0];
    } else {
      in(l), in(r), scanf("%s", ch);
      len = strlen(ch), ans = 0;
      for (int i = 0; i < len; ++i)
        ans += query(l, r, (i + l - 1) % len, b[ch[i]], len);
      printf("%d\n", ans);
    }
  }
  return 0;
}
