#include <bits/stdc++.h>
using namespace std;
int get(char c) {
  if (c == 'A') return 0;
  if (c == 'T') return 1;
  if (c == 'G') return 2;
  return 3;
}
int bit[100007][4][11][11];
void upd(int idx, int t, int a, int d, int v) {
  while (idx < 100007) {
    bit[idx][t][a][d] += v;
    idx += (idx & -idx);
  }
}
int read(int idx, int t, int a, int d) {
  int ret = 0;
  while (idx) {
    ret += bit[idx][t][a][d];
    idx -= (idx & -idx);
  }
  return ret;
}
int main() {
  string s;
  cin >> s;
  s = "#" + s;
  for (int i = (1); i < (s.size()); i++) {
    for (int a = (1); a < (11); a++) {
      for (int d = (1); d < (11); d++) {
        int o = i - a;
        if (o >= 0 && o % d == 0) {
          upd(i, get(s[i]), a, d, 1);
        }
      }
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int idx;
      char c;
      scanf("%d", &idx);
      cin >> c;
      for (int a = (1); a < (11); a++) {
        for (int d = (1); d < (11); d++) {
          int o = idx - a;
          if (o >= 0 && o % d == 0) {
            upd(idx, get(s[idx]), a, d, -1);
            upd(idx, get(c), a, d, 1);
          }
        }
      }
      s[idx] = c;
    } else {
      int l, r;
      string c;
      scanf("%d %d", &l, &r);
      cin >> c;
      int d = c.size();
      int now = l;
      int ans = 0;
      for (int i = 0; i < d; i++, now++) {
        int a = (now - 1) % d + 1;
        ans += read(r, get(c[i]), a, d) - read(l - 1, get(c[i]), a, d);
      }
      printf("%d\n", ans);
    }
  }
}
