#include <bits/stdc++.h>
using namespace std;
int n, bit[4][11][10][100010];
void add(int a, int b, int c, int idx, int val) {
  while (idx <= n) {
    bit[a][b][c][idx] += val;
    idx += (idx & -idx);
  }
}
int get(int a, int b, int c, int idx) {
  int ret = 0;
  while (idx > 0) {
    ret += bit[a][b][c][idx];
    idx -= (idx & -idx);
  }
  return ret;
}
int mp[300];
int main() {
  string s, e;
  int i, j, q, type, idx, l, r, ret;
  mp['A'] = 0, mp['T'] = 1, mp['G'] = 2, mp['C'] = 3;
  cin >> s;
  n = s.size();
  for (i = 0; i < n; i++) {
    for (j = 1; j <= 10; j++) {
      add(mp[s[i]], j, (i + 1) % j, (i + 1), 1);
    }
  }
  cout << endl;
  cin >> q;
  while (q--) {
    cin >> type;
    if (type == 1) {
      cin >> idx >> e;
      for (j = 1; j <= 10; j++) add(mp[s[idx - 1]], j, idx % j, idx, -1);
      s[idx - 1] = e[0];
      for (j = 1; j <= 10; j++) add(mp[s[idx - 1]], j, idx % j, idx, 1);
    } else {
      cin >> l >> r >> e;
      int len = e.size();
      int ret = 0;
      for (i = 0; i < len; i++) {
        ret += (get(mp[e[i]], len, (l + i) % len, r) -
                get(mp[e[i]], len, (l + i) % len, l - 1));
      }
      cout << ret << endl;
    }
  }
}
