#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const long long linf = (long long)1e18;
const double eps = (double)1e-8;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
int numb(char c) {
  if (c == 'A') return 0;
  if (c == 'T') return 1;
  if (c == 'G') return 2;
  return 3;
}
int cnt;
string st;
vector<int> t[444];
int ln[444], sd[444];
int len[11][11];
int num[11][11][5];
void build(int z, int v, int l, int r, int c) {
  if (l > r) return;
  if (l == r) {
    t[z][v] = (numb(st[ln[z] * (l - 1) + sd[z] + 1]) == c);
    return;
  }
  int m = (l + r) / 2;
  build(z, 2 * v, l, m, c);
  build(z, 2 * v + 1, m + 1, r, c);
  t[z][v] = t[z][2 * v] + t[z][2 * v + 1];
  return;
}
void upd(int z, int v, int l, int r, int pos, int newval) {
  if (l > r || pos < l || pos > r) return;
  if (l == r) {
    t[z][v] = newval;
    return;
  }
  int m = (l + r) / 2;
  upd(z, 2 * v, l, m, pos, newval);
  upd(z, 2 * v + 1, m + 1, r, pos, newval);
  t[z][v] = t[z][2 * v] + t[z][2 * v + 1];
  return;
}
int sum(int z, int v, int l, int r, int tl, int tr) {
  if (l > r || tl > tr) return 0;
  if (l == tl && r == tr) {
    return t[z][v];
  }
  int m = (l + r) / 2;
  return sum(z, 2 * v, l, m, tl, min(tr, m)) +
         sum(z, 2 * v + 1, m + 1, r, max(tl, m + 1), tr);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> st;
  st = "_" + st;
  cnt = 0;
  for (int i = (1); i <= (int)(10); ++i) {
    for (int j = (0); j <= (int)(i - 1); ++j) {
      len[i][j] = (st.size() - 1) / i;
      if ((st.size() - 1) % i > j) ++len[i][j];
      if (i == 4) {
      }
      for (int k = (0); k <= (int)(3); ++k) {
        num[i][j][k] = ++cnt;
        ln[cnt] = i;
        sd[cnt] = j;
        for (int q = (0); q <= (int)(4 * len[i][j]); ++q) t[cnt].push_back(0);
        build(cnt, 1, 1, len[i][j], k);
      }
    }
  }
  int T;
  cin >> T;
  for (int(numt) = (1); (numt) <= (int)(T); ++(numt)) {
    int typ;
    cin >> typ;
    if (typ == 1) {
      int x;
      char c;
      cin >> x >> c;
      int y = numb(c);
      for (int i = (1); i <= (int)(10); ++i) {
        int z = (x - 1) % i;
        upd(num[i][z][numb(st[x])], 1, 1, len[i][z], (x - 1) / i + 1, 0);
        upd(num[i][z][y], 1, 1, len[i][z], (x - 1) / i + 1, 1);
      }
      st[x] = c;
    } else {
      int l, r;
      string e;
      int sz;
      int ans = 0;
      cin >> l >> r >> e;
      sz = e.size();
      for (int i = (0); i < (int)(e.size()); ++i) {
        int tr;
        if ((r - 1) % sz < (l + i - 1) % sz)
          tr = (r - 1) / sz;
        else
          tr = (r - 1) / sz + 1;
        ans += sum(num[sz][(l + i - 1) % sz][numb(e[i])], 1, 1,
                   len[sz][(l + i - 1) % sz], (l + i - 1) / sz + 1, tr);
      }
      cout << ans << "\n";
    }
  }
  return 0;
}
