#include <bits/stdc++.h>
using namespace std;
int dic[4][11][11][100010], n;
inline int lowbit(int _x) { return _x & -_x; }
inline void modify(int* bit, int pos, int add) {
  for (int i = pos; i <= n; i += lowbit(i)) {
    bit[i] += add;
  }
}
inline int query(int* bit, int pos) {
  int res = 0;
  for (int i = pos; i > 0; i -= lowbit(i)) {
    res += bit[i];
  }
  return res;
}
inline int getId(char ch) {
  if (ch == 'A') return 0;
  if (ch == 'C') return 1;
  if (ch == 'T') return 2;
  return 3;
}
char str[100010];
int main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for (int i = 1; i <= n; i++) {
    int id = getId(str[i]);
    for (int j = 1; j <= 10; j++) {
      modify(dic[id][j][i % j], i, 1);
    }
  }
  int q, op, x, l, r;
  char ch[2], e[15];
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%s", &x, ch);
      char now = str[x];
      int id = getId(now);
      for (int j = 1; j <= 10; j++) {
        modify(dic[id][j][x % j], x, -1);
      }
      now = ch[0];
      id = getId(now);
      for (int j = 1; j <= 10; j++) {
        modify(dic[id][j][x % j], x, 1);
      }
      str[x] = now;
    } else {
      scanf("%d%d%s", &l, &r, e);
      int len = strlen(e), a = 0, b = 0;
      for (int i = 0; i < len; i++) {
        int id = getId(e[i]);
        a += query(dic[id][len][(l + i) % len], l - 1);
        b += query(dic[id][len][(l + i) % len], r);
      }
      printf("%d\n", b - a);
    }
  }
  return 0;
}
