#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + (s - '0');
    s = getchar();
  }
  return x * f;
}
const int jzm = 1000000007;
int n, m, i, j, s, o, k;
char A[100005], ss[15];
int nm[400], a[100005], b[15];
int t[11][10][4][100005];
void addt(int *t, int x, int y) {
  while (x <= n) t[x] += y, x += ((-x) & (x));
  return;
}
int sumt(int *t, int x) {
  int as = 0;
  while (x > 0) as += t[x], x -= ((-x) & (x));
  return as;
}
int findt(int *t, int l, int r) { return sumt(t, r) - sumt(t, l - 1); }
int main() {
  nm['A'] = 0;
  nm['T'] = 1;
  nm['G'] = 2;
  nm['C'] = 3;
  scanf("%s", A + 1);
  n = strlen(A + 1);
  for (int i = 1; i <= n; i++) {
    a[i] = nm[A[i]];
    for (int j = 1; j <= 10; j++) {
      addt(t[j][i % j][a[i]], i, 1);
    }
  }
  m = read();
  for (int i = 1; i <= m; i++) {
    k = read();
    if (k == 1) {
      s = read();
      char ss;
      cin >> ss;
      int b = nm[ss];
      for (int j = 1; j <= 10; j++) {
        addt(t[j][s % j][a[s]], s, -1);
        addt(t[j][s % j][b], s, 1);
      }
      a[s] = b;
    } else {
      s = read();
      o = read();
      scanf("%s", ss + 1);
      int nb = strlen(ss + 1), ans = 0;
      for (int j = 1; j <= nb; j++) b[j] = nm[ss[j]];
      for (int j = 1; j <= nb; j++) {
        int ad = s + j - 1;
        ans += findt(t[nb][ad % nb][b[j]], s, o);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
