#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
const int maxM = (int)1e6 + 100;
const int mod = (int)1e9 + 7;
const int maxlog = (int)20;
string second;
int n, m;
struct T {
  int t[maxn];
  inline void upd(int pos, int val) {
    for (; pos < maxn; pos = (pos | (pos + 1))) t[pos] += val;
  }
  inline int get(int r) {
    int res = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) res += t[r];
    return res;
  }
  inline int get(int l, int r) { return get(r) - get(l - 1); }
} t[5][11][11];
inline int type(char second) {
  if (second == 'A') return 1;
  if (second == 'T') return 2;
  if (second == 'G')
    return 3;
  else
    return 4;
}
int main() {
  cin >> second;
  n = second.size();
  second = '#' + second;
  for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= n; j++) {
      t[type(second[j])][i][j % i].upd(j, 1);
    }
  }
  cin >> m;
  while (m--) {
    int ttype, l, r, pos;
    string e;
    char x;
    cin >> ttype;
    if (ttype == 1) {
      cin >> pos >> x;
      if (second[pos] != x) {
        for (int i = 1; i <= 10; i++) {
          t[type(second[pos])][i][pos % i].upd(pos, -1);
          t[type(x)][i][pos % i].upd(pos, 1);
        }
        second[pos] = x;
      }
    } else {
      cin >> l >> r >> e;
      int ans = 0;
      for (int i = 0; i < e.size(); i++, l++) {
        ans += t[type(e[i])][e.size()][l % (e.size())].get(l, r);
      }
      cout << ans << endl;
    }
  }
}
