#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 69;
const long long mod = 1e9 + 7;
const long long inv2 = (mod + 1) / 2ll;
const long long inv32 = 281250002ll;
const double pi = acos(-1.0);
const int MX = 100005;
int BIT[MX][4][10][10];
void upd(int ps, int tp1, int tp2, int tp3, int val) {
  for (; ps < MX; ps += ps & -ps) BIT[ps][tp1][tp2][tp3] += val;
}
int que(int ps, int tp1, int tp2, int tp3) {
  int rs = 0;
  for (; ps > 0; ps -= ps & -ps) rs += BIT[ps][tp1][tp2][tp3];
  return rs;
}
string s;
int n, q, tp, l, r, x;
char c;
string e;
int rev(char x) {
  if (x == 'A') return 0;
  if (x == 'T') return 1;
  if (x == 'G') return 2;
  if (x == 'C') return 3;
  return -1;
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++) {
    int tp1 = rev(s[i]);
    for (int j = 0; j < 10; j++) {
      int diff = i % (j + 1);
      upd(i + 1, tp1, diff, j, 1);
    }
  }
  cin >> q;
  for (int sz; q--;) {
    cin >> tp;
    if (tp == 1) {
      cin >> x >> c;
      x--;
      int tp1 = rev(s[x]);
      for (int j = 0; j < 10; j++) {
        int diff = x % (j + 1);
        upd(x + 1, tp1, diff, j, -1);
      }
      s[x] = c;
      tp1 = rev(s[x]);
      for (int j = 0; j < 10; j++) {
        int diff = x % (j + 1);
        upd(x + 1, tp1, diff, j, 1);
      }
    } else {
      cin >> l >> r >> e;
      sz = e.size();
      l--;
      r--;
      int ans = 0;
      for (int j = 0; j < sz; j++) {
        int LF = l + j;
        if (LF > r) break;
        int RG = r;
        while (RG % sz != LF % sz) RG--;
        if (LF > RG) continue;
        int typ = rev(e[j]);
        ans += que(RG + 1, typ, LF % sz, sz - 1) -
               que(LF + 1 - sz, typ, LF % sz, sz - 1);
      }
      cout << ans << "\n";
    }
  }
  return 0;
}
