#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10, MN = 1e5 + 5;
string s;
int n, fen[MN][11][11][4];
map<char, int> mp = {make_pair('A', 0), make_pair('T', 1), make_pair('C', 2),
                     make_pair('G', 3)};
int get(int p, int len, int x, int y) {
  int res = 0;
  for (; p; p -= p & -p) res += fen[p][len][x][y];
  return res;
}
void add(int p, int w, int x) {
  int y = p;
  for (p++; p < MN; p += p & -p)
    for (int i = 1; i < 11; ++i) fen[p][i][y % i][w] += x;
}
void solve() {
  int q;
  cin >> q;
  while (q--) {
    int tp;
    cin >> tp;
    if (tp == 1) {
      int p;
      char c;
      cin >> p >> c;
      add(p - 1, mp[s[p - 1]], -1), s[p - 1] = c;
      add(p - 1, mp[s[p - 1]], 1);
    } else {
      int l, r;
      string T;
      cin >> l >> r >> T;
      --l;
      int ans = 0;
      for (int i = 0; i < ((int)(T).size()); ++i)
        ans +=
            get(r, ((int)(T).size()), (i + l) % ((int)(T).size()), mp[T[i]]) -
            get(l, ((int)(T).size()), (i + l) % ((int)(T).size()), mp[T[i]]);
      cout << ans << '\n';
    }
  }
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> s;
  n = ((int)(s).size());
  for (int i = 0; i < n; ++i) add(i, mp[s[i]], 1);
  solve();
  return 0;
}
