#include <bits/stdc++.h>
using namespace std;
enum DNA_LETTER { A, T, G, C };
DNA_LETTER charToDnaLetter(char c) {
  if (c == 'A') return A;
  if (c == 'T') return T;
  if (c == 'G') return G;
  return C;
}
struct FenwickTree {
  vector<int> a;
  FenwickTree() {}
  FenwickTree(int n) { a.resize(n); }
  void add(int pos, int delta) {
    for (; pos < a.size(); pos = pos | (pos + 1)) a[pos] += delta;
  }
  int get(int pos) {
    int ret = 0;
    for (; pos >= 0; pos = (pos & (pos + 1)) - 1) ret += a[pos];
    return ret;
  }
  int sum(int l, int r) { return get(r) - get(l - 1); }
};
int main() {
  char buf[100005];
  scanf("%s", buf);
  int len = strlen(buf);
  vector<DNA_LETTER> dna(len);
  for (int i = 0; i < len; ++i) dna[i] = charToDnaLetter(buf[i]);
  vector<vector<FenwickTree>> fen[4];
  for (int i = 0; i < 4; ++i) {
    fen[i].resize(11);
    for (int j = 1; j <= 10; ++j) {
      fen[i][j].resize(j);
      for (int k = 0; k < j; ++k) fen[i][j][k] = FenwickTree(len / j + 1);
    }
  }
  for (int i = 0; i < len; ++i)
    for (int j = 1; j <= 10; ++j) fen[dna[i]][j][i % j].add(i / j, 1);
  int q;
  scanf("%d", &q);
  while (q--) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int x;
      char c;
      scanf("%d %c", &x, &c);
      x--;
      for (int j = 1; j <= 10; ++j) fen[dna[x]][j][x % j].add(x / j, -1);
      dna[x] = charToDnaLetter(c);
      for (int j = 1; j <= 10; ++j) fen[dna[x]][j][x % j].add(x / j, 1);
    } else {
      int l, r;
      char e[11];
      scanf("%d %d %s", &l, &r, e);
      int e_len = strlen(e);
      l--, r--;
      int ans = 0;
      for (int e_pos = 0; e_pos < min(e_len, r - l + 1); ++e_pos) {
        DNA_LETTER let = charToDnaLetter(e[e_pos]);
        ans += fen[let][e_len][(l + e_pos) % e_len].sum(
            (l + e_pos) / e_len, (l + e_pos) / e_len + (r - l - e_pos) / e_len);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
