#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int bit[maxn][11][10][4];
char s[maxn];
char e[11];
int n, q, m, l, r;
int tp, pos;
char t;
int trans(char p) {
  if (p == 'A')
    return 0;
  else if (p == 'T')
    return 1;
  else if (p == 'C')
    return 2;
  return 3;
}
int lowbit(int p) { return p & (-p); }
void add(int p, int i, int j, int k) {
  while (p <= n) {
    bit[p][i][j][k]++;
    p += lowbit(p);
  }
  return;
}
void remov(int p, int i, int j, int k) {
  while (p <= n) {
    bit[p][i][j][k]--;
    p += lowbit(p);
  }
  return;
}
int cnt(int p, int i, int j, int k) {
  int ans = 0;
  while (p > 0) {
    ans += bit[p][i][j][k];
    p -= lowbit(p);
  }
  return ans;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) add(i, j, i % j, trans(s[i]));
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &tp);
    if (tp == 1) {
      scanf("%d", &pos);
      t = getchar();
      t = getchar();
      for (int i = 1; i <= 10; i++) {
        remov(pos, i, pos % i, trans(s[pos]));
        add(pos, i, pos % i, trans(t));
      }
      s[pos] = t;
    } else {
      scanf("%d%d", &l, &r);
      scanf("%s", e + 1);
      m = strlen(e + 1);
      int ans = 0;
      for (int i = 1; i <= m; i++) {
        int mod = (l + i - 1) % m;
        ans += cnt(r, m, mod, trans(e[i])) - cnt(l - 1, m, mod, trans(e[i]));
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
