#include <bits/stdc++.h>
using namespace std;
long long t, n, m, u, v, q, k;
const int N = 1e5 + 500;
const int LN = 21;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
long long arr[N];
string str, ss;
map<char, int> M;
int tree[4][10][10][N];
void modify(int tree[], int v, int val) {
  while (v < N) {
    tree[v] += val;
    v += (v & -v);
  }
}
int query(int tree[], int v) {
  int ret = 0;
  while (v > 0) {
    ret += tree[v];
    v -= (v & -v);
  }
  return ret;
}
int query(int tree[], int l, int r) {
  return query(tree, r) - query(tree, l - 1);
}
int solve(int l, int r, string e) {
  int ret = 0;
  if ((r - l + 1) % e.size() != 0) {
    int x = (r - l + 1) % e.size();
    for (int j = x - 1; j >= 0; --j) {
      if (e[j] == str[r]) ret++;
      r--;
    }
  }
  for (int i = 0; i < e.size(); ++i) {
    ret += query(tree[M[e[i]]][e.size() - 1][(i + l) % e.size()], l, r);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ss = "ACTG";
  cin >> str;
  n = str.size();
  for (int i = 0; i < ss.size(); ++i) M[ss[i]] = i;
  str = "$" + str;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 10; ++j) {
      modify(tree[M[str[i]]][j - 1][i % j], i, 1);
    }
  }
  cin >> q;
  while (q--) {
    int type;
    cin >> type;
    if (type == 1) {
      int x;
      char c;
      cin >> x >> c;
      int i = x;
      for (int j = 1; j <= 10; ++j) {
        modify(tree[M[str[i]]][j - 1][i % j], i, -1);
        modify(tree[M[c]][j - 1][i % j], i, 1);
      }
      str[x] = c;
    } else {
      int l, r;
      string e;
      cin >> l >> r >> e;
      cout << solve(l, r, e) << '\n';
    }
  }
  return 0;
}
