#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
struct Bit {
  int ar[N];
  void update(int x, int val) {
    for (; x <= n; x += x & -x) ar[x] += val;
  }
  int query(int x) {
    int sum = 0;
    for (; x > 0; x -= x & -x) sum += ar[x];
    return sum;
  }
  int query(int x, int y) { return query(y) - query(x - 1); }
} bit[11][11][5];
char ch[N];
int q;
unordered_map<char, int> mp;
int main() {
  mp.clear();
  mp['A'] = 0;
  mp['T'] = 1;
  mp['G'] = 2;
  mp['C'] = 3;
  for (int i = 0; i < 11; i++)
    for (int j = 0; j < 11; j++)
      for (int k = 0; k < 5; k++)
        for (int z = 0; z < N; z++) bit[i][j][k].ar[z] = 0;
  scanf("%s", ch + 1);
  n = strlen(ch + 1);
  for (int i = 1; i <= 10; i++)
    for (int j = 1; j <= n; j++) bit[i][j % i][mp[ch[j]]].update(j, 1);
  scanf("%d", &q);
  while (q--) {
    int temp, x, l, r;
    char e[15];
    scanf("%d", &temp);
    if (temp == 1) {
      scanf("%d %s", &x, e);
      for (int i = 1; i <= 10; i++) {
        bit[i][x % i][mp[ch[x]]].update(x, -1);
        bit[i][x % i][mp[e[0]]].update(x, 1);
      }
      ch[x] = e[0];
    } else {
      int ans = 0;
      scanf("%d %d %s", &l, &r, e);
      int len = strlen(e);
      for (int i = 0; i < len; i++) {
        ans += (bit[len][(l + i) % len][mp[e[i]]].query(l, r));
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
