#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int BIT[4][11][MAXN * 2], n;
void add(int BIT[], int p, int x) {
  for (int i = p; i <= n; i += ((i) & (-(i)))) BIT[i] += x;
}
int ask(int BIT[], int p) {
  int res = 0;
  for (int i = p; i; i -= ((i) & (-(i)))) res += BIT[i];
  return res;
}
char str[MAXN], tmp[11];
;
int biao[233];
int HASH(int i, int Base) {
  --i;
  return i / Base + (i % Base) * (n / Base) + min(i % Base, n % Base) + 1;
}
int main(void) {
  biao['A'] = 0;
  biao['G'] = 1;
  biao['C'] = 2;
  biao['T'] = 3;
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for (int i = 1; i <= n; ++i) {
    str[i] = biao[str[i]];
    for (int Base = 1; Base <= 10; ++Base) {
      add(BIT[str[i]][Base], HASH(i, Base), 1);
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int op, l, r;
    scanf("%d%d", &op, &l);
    if (op == 1) {
      scanf("%s", tmp);
      for (int Base = 1; Base <= 10; ++Base)
        add(BIT[str[l]][Base], HASH(l, Base), -1);
      str[l] = biao[tmp[0]];
      for (int Base = 1; Base <= 10; ++Base)
        add(BIT[str[l]][Base], HASH(l, Base), 1);
    } else {
      scanf("%d%s", &r, tmp);
      int Base = min(int(strlen(tmp)), r - l + 1), res = 0;
      for (int i = 0; i < Base; ++i) {
        res += ask(BIT[biao[tmp[i]]][Base],
                   HASH((r - l - i) / Base * Base + l + i, Base)) -
               ask(BIT[biao[tmp[i]]][Base], HASH(l + i, Base) - 1);
      }
      printf("%d\n", res);
    }
  }
  return 0;
}
