#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline int wh(char ch) {
  if (ch == 'A') return 0;
  if (ch == 'T') return 1;
  if (ch == 'G') return 2;
  if (ch == 'C') return 3;
  return 4;
}
int tree[4][11][11][100007], n;
char s[100007], t[100007];
void update(int i, int k, int r, int idx, int val) {
  while (idx <= n) {
    tree[i][k][r][idx] += val;
    idx += (idx & -idx);
  }
}
int query(int i, int k, int r, int idx) {
  int sum = 0;
  while (idx) {
    sum += tree[i][k][r][idx];
    idx -= (idx & -idx);
  }
  return sum;
}
int main() {
  int i, j, k, r, l, tp, pos, q, len, sum;
  scanf("%s", &s[1]);
  n = strlen(&s[1]);
  for (i = 1; s[i]; i++) {
    j = wh(s[i]);
    for (k = 1; k <= 10; k++) {
      r = (i - 1) % k + 1;
      update(j, k, r, i, +1);
    }
  }
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &tp);
    if (tp == 1) {
      scanf("%d %s", &pos, t);
      for (k = 1; k <= 10; k++) {
        r = (pos - 1) % k + 1;
        update(wh(s[pos]), k, r, pos, -1);
        update(wh(t[0]), k, r, pos, +1);
      }
      s[pos] = t[0];
    } else {
      scanf("%d %d %s", &l, &r, t);
      sum = 0;
      len = strlen(t);
      for (i = 0, j = l; t[i] && j <= r; i++, j++) {
        sum += query(wh(t[i]), len, (j - 1) % len + 1, r);
        sum -= query(wh(t[i]), len, (j - 1) % len + 1, l - 1);
      }
      cout << sum << endl;
    }
  }
  return 0;
}
