#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 7;
int T[12][12][4][MAXN];
int n;
void add(int a, int b, int c, int d, int x) {
  while (d <= n) T[a][b][c][d] += x, d += d & -d;
}
int sum(int a, int b, int c, int d) {
  int res = 0;
  while (d) res += T[a][b][c][d], d -= d & -d;
  return res;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  map<char, int> mmp;
  mmp['A'] = 0;
  mmp['T'] = 1;
  mmp['G'] = 2;
  mmp['C'] = 3;
  string s;
  cin >> s;
  n = s.length();
  for (int i = 0; i < n; i++)
    for (int j = 1; j < 11; j++) add(i % j, j, mmp[s[i]], i + 1, 1);
  int q;
  cin >> q;
  while (q--) {
    int k;
    cin >> k;
    if (k == 1) {
      int x;
      char c;
      cin >> x >> c;
      x--;
      for (int j = 1; j < 11; j++) {
        add(x % j, j, mmp[s[x]], x + 1, -1);
        add(x % j, j, mmp[c], x + 1, 1);
      }
      s[x] = c;
    } else {
      int l, r;
      string e;
      cin >> l >> r >> e;
      l--, r--;
      int len = e.length();
      int res = 0;
      for (int i = 0; i < len; i++)
        res += sum((l + i) % len, len, mmp[e[i]], r + 1) -
               sum((l + i) % len, len, mmp[e[i]], l);
      cout << res << endl;
    }
  }
  return 0;
}
