#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int tree[4][11][11][maxn];
void add(int letter, int mod, int parity, int k, int v) {
  for (int i = k; i < maxn; i += i & -i) tree[letter][mod][parity][i] += v;
}
int qry(int letter, int mod, int parity, int k) {
  int res = 0;
  for (int i = k; i >= 1; i -= i & -i) res += tree[letter][mod][parity][i];
  return res;
}
int get(char c) {
  if (c == 'A') return 0;
  if (c == 'T') return 1;
  if (c == 'G') return 2;
  if (c == 'C') return 3;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 11; j++)
      for (int k = 0; k < 11; k++)
        for (int l = 0; l < maxn; l++) tree[i][j][k][l] = 0;
  string s;
  cin >> s;
  for (int i = 1; i <= s.length(); i++) {
    int c = get(s[i - 1]);
    for (int mod = 1; mod <= 10; mod++) {
      add(c, mod, i % mod, i, 1);
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      int x;
      char y;
      cin >> x >> y;
      int old = get(s[x - 1]);
      int c = get(y);
      s[x - 1] = y;
      for (int mod = 1; mod <= 10; mod++) {
        add(old, mod, x % mod, x, -1);
        add(c, mod, x % mod, x, 1);
      }
    } else {
      int l, r;
      string e;
      cin >> l >> r >> e;
      int mod = e.length();
      int res = 0;
      for (int j = 0; j < e.length(); j++) {
        int contrib = qry(get(e[j]), mod, (l + j) % mod, r) -
                      qry(get(e[j]), mod, (l + j) % mod, l - 1);
        res += contrib;
      }
      cout << res << '\n';
    }
  }
}
