#include <bits/stdc++.h>
const int MAXN = 100005;
char s[MAXN];
using namespace std;
struct Node {
  int* value[4][11];
} tree[MAXN];
void build_tree(int n) {
  for (int x = 1; x <= n; x++)
    for (int i = 0; i < 4; i++)
      for (int j = 1; j <= 10; j++) {
        tree[x].value[i][j] = new int[j];
        for (int k = 0; k < j; k++) tree[x].value[i][j][k] = 0;
      }
}
void update(int pos, int i, int value, int n) {
  for (int x = pos; x <= n; x += ((x) & (-x)))
    for (int j = 1; j <= 10; j++) tree[x].value[i][j][(pos - 1) % j] += value;
}
int query(int x, int i, int j, int k) {
  int ret = 0;
  while (x) {
    ret += tree[x].value[i][j][k];
    x -= ((x) & (-x));
  }
  return ret;
}
inline int change(char c) {
  switch (c) {
    case 'A':
      return 0;
    case 'T':
      return 1;
    case 'G':
      return 2;
    case 'C':
      return 3;
  }
}
int main() {
  scanf("%s", s);
  int n = strlen(s);
  build_tree(n);
  for (int i = 0; i < n; i++) update(i + 1, change(s[i]), 1, n);
  int q;
  scanf("%d", &q);
  while (q--) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int x;
      char c;
      scanf("%d %c", &x, &c);
      update(x, change(s[x - 1]), -1, n);
      update(x, change(c), 1, n);
      s[x - 1] = c;
    } else {
      int l, r;
      char e[15];
      scanf("%d%d%s", &l, &r, e);
      int m = strlen(e);
      int ans = 0;
      for (int i = 0; e[i]; i++) {
        int temp = query(r, change(e[i]), m, (l + i - 1) % m) -
                   query(l - 1, change(e[i]), m, (l + i - 1) % m);
        ans += temp;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
