#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int c[4][11][11][maxn + 5];
char s[maxn + 50];
char t[15];
int n;
int getnum(char c) {
  if (c == 'A') return 0;
  if (c == 'T') return 1;
  if (c == 'G') return 2;
  if (c == 'C') return 3;
}
int lowbit(int x) { return x & (-x); }
void add(int *c, int k, int x) {
  for (int i = k; i <= n; i += lowbit(i)) {
    c[i] += x;
  }
}
int query(int *c, int k) {
  int ans = 0;
  for (int i = k; i; i -= lowbit(i)) ans += c[i];
  return ans;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int ch = 0; ch < 4; ++ch)
    for (int i = 1; i <= 10; ++i)
      for (int j = 1; j <= i; ++j)
        for (int k = j; k <= n; k += i)
          if (getnum(s[k]) == ch) {
            add(c[ch][i][j], (k - j) / i + 1, 1);
          }
  int q;
  scanf("%d", &q);
  while (q--) {
    int op, x, l, r;
    char ch;
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d %c", &x, &ch);
      int id = getnum(s[x]);
      for (int i = 1; i <= 10; ++i) {
        int j = x % i;
        if (j == 0) j = i;
        add(c[id][i][j], (x - j) / i + 1, -1);
      }
      s[x] = ch;
      id = getnum(s[x]);
      for (int i = 1; i <= 10; ++i) {
        int j = x % i;
        if (j == 0) j = i;
        add(c[id][i][j], (x - j) / i + 1, 1);
      }
    }
    if (op == 2) {
      scanf("%d%d%s", &l, &r, t + 1);
      int len = strlen(t + 1);
      int ans = 0;
      for (int k = 1; k <= len && k <= r - l + 1; ++k) {
        int id = getnum(t[k]);
        int i = len;
        int j = (l + k - 1) % i;
        if (j == 0) j = i;
        ans += query(c[id][i][j], (r - j) / i + 1) -
               query(c[id][i][j], (l + k - 1 - j) / i);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
