#include <bits/stdc++.h>
using namespace std;
int n, a[100005], ys[100005], q;
char s[100005];
struct BIT {
  int c[100005];
  void add(int x, int z) {
    for (; x <= n; x += (x & (-x))) c[x] += z;
  }
  int query(int x) {
    int sum = 0;
    for (; x > 0; x -= (x & (-x))) sum += c[x];
    return sum;
  }
  int sum(int l, int r) { return query(r) - query(l - 1); }
} T[4][10][10];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  ys['A'] = 0;
  ys['C'] = 1;
  ys['G'] = 2;
  ys['T'] = 3;
  for (int i = 1; i <= n; i++) a[i] = ys[s[i]];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 10; j++) T[a[i]][j - 1][i % j].add(i, 1);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int opt, l, r;
    scanf("%d", &opt);
    if (opt == 1) {
      scanf("%d%s", &l, s);
      for (int j = 1; j <= 10; j++) T[a[l]][j - 1][l % j].add(l, -1);
      a[l] = ys[s[0]];
      for (int j = 1; j <= 10; j++) T[a[l]][j - 1][l % j].add(l, 1);
    } else {
      scanf("%d%d%s", &l, &r, s + 1);
      int len = strlen(s + 1);
      int ans = 0;
      for (int j = 1; j <= len; j++)
        ans += T[ys[s[j]]][len - 1][(l + j - 1) % len].sum(l, r);
      printf("%d\n", ans);
    }
  }
  return 0;
}
