#include <bits/stdc++.h>
using namespace std;
char ch[100005], e[104], c;
int d[105005][7], elen, ans, m[500], n, q, t, x, l, r;
int main() {
  m['A'] = 0, m['T'] = 1, m['G'] = 2, m['C'] = 3;
  scanf("%s", ch), n = strlen(ch);
  scanf("%d", &q);
  for (int i = 0; i < n; i++) {
    d[i][m[ch[i]]]++;
    for (int j = 0; j < 4; j++) d[i + 2520][j] += d[i][j];
  }
  while (q-- && scanf("%d", &t)) {
    if (t == 1) {
      scanf("%d %c", &x, &c), x--;
      for (int i = x; i < n; i += 2520) d[i][m[ch[x]]]--, d[i][m[c]]++;
      ch[x] = c;
    } else {
      scanf("%d%d%s", &l, &r, e), l--, r--, ans = 0, elen = strlen(e);
      for (int i = l; i < l + elen; i++)
        for (int j = i; j <= min(r, l + 2520 - 1); j += elen)
          ans += d[((r - j) / 2520) * 2520 + j][m[e[i - l]]] -
                 d[j][m[e[i - l]]] + (ch[j] == e[i - l]);
      printf("%d\n", ans);
    }
  }
  return 0;
}
