#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int n, ans;
string s, ss;
int f[11][4][10][100005];
int N = 100005;
int type(char ch) {
  if (ch == 'A') return 0;
  if (ch == 'T') return 1;
  if (ch == 'G') return 2;
  return 3;
}
void upd(int j, int typ, int id, int pos, int val) {
  for (; pos < N; pos |= pos + 1) f[j][typ][id][pos] += val;
}
int sum(int j, int typ, int id, int x) {
  int res = 0;
  for (; x >= 0; x = (x & (x + 1)) - 1) res += f[j][typ][id][x];
  return res;
}
int get(int j, int typ, int id, int l, int r) {
  return sum(j, typ, id, r) - sum(j, typ, id, l - 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  s = "#" + s;
  for (int i = 1; i < s.size(); i++) {
    for (int j = 1; j <= 10; j++) {
      upd(j, type(s[i]), i % j, i, 1);
    }
  }
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int ty;
    cin >> ty;
    if (ty == 1) {
      int x;
      char c;
      cin >> x >> c;
      if (s[x] != c) {
        for (int j = 1; j <= 10; j++) {
          upd(j, type(s[x]), x % j, x, -1);
          upd(j, type(c), x % j, x, 1);
        }
        s[x] = c;
      }
    } else {
      int l, r;
      cin >> l >> r >> ss;
      ans = 0;
      for (int j = 0; j < ss.size(); j++, l++) {
        ans += get(ss.size(), type(ss[j]), l % ss.size(), l, r);
      }
      cout << ans << "\n";
    }
  }
  return 0;
}
