#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5 + 69;
char bb[MX];
int nig[1 << 10];
int bit[1 << 17][11][4][11];
void insert(int x, int j, int k, int z, int v) {
  while (x < (1 << 17)) {
    bit[x][j][k][z] += v;
    x += x & (-x);
  }
}
int get(int x, int j, int k, int z) {
  int ret = 0;
  while (x) {
    ret += bit[x][j][k][z];
    x -= x & (-x);
  }
  return ret;
}
int main() {
  nig['A'] = 0, nig['T'] = 1, nig['G'] = 2, nig['C'] = 3;
  scanf("%s", bb);
  int n = strlen(bb);
  for (int z = 1; z <= 10; z++)
    for (int j = 0; j < z; j++)
      for (int i = j; i < n; i += z) insert(i + 1, j, nig[bb[i]], z, 1);
  int q;
  cin >> q;
  while (q--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int id;
      char c;
      scanf("%d %c", &id, &c);
      for (int z = 1; z <= 10; z++) {
        insert(id, (id - 1) % z, nig[bb[id - 1]], z, -1);
        insert(id, (id - 1) % z, nig[c], z, 1);
      }
      bb[id - 1] = c;
    } else {
      int l, r;
      char virus[11];
      scanf("%d %d %s", &l, &r, virus);
      int D = strlen(virus);
      int quer = 0;
      for (int i = 0; i < D; i++) {
        quer += get(r, (l - 1 + i) % D, nig[virus[i]], D) -
                get(l - 1, (l - 1 + i) % D, nig[virus[i]], D);
      }
      printf("%d\n", quer);
    }
  }
  return 0;
}
