#include <bits/stdc++.h>
using namespace std;
char str[200010], s[20];
int st[2520], ed[2520];
int cnt[7][50][2520];
char DNA[5] = "ACGT";
int hgm(char c) {
  if (c == 'A') return 0;
  if (c == 'C') return 1;
  if (c == 'G') return 2;
  if (c == 'T') return 3;
  return 4;
}
int main() {
  scanf("%s", str);
  int L = strlen(str);
  int N = L - L % 2520 + 2520;
  if (L % 2520 == 0) N -= 2520;
  int K = N / 2520;
  for (int i = L; i < N; i++) str[i] = '*';
  str[N] = 0;
  for (int i = 0, k = 0; i < K; i++)
    for (int j = 0; j < 2520; j++) cnt[hgm(str[k++])][i][j] = 1;
  for (int i = K - 2; i >= 0; i--)
    for (int j = 0; j < 2520; j++)
      for (int k = 0; k < 4; k++) cnt[k][i][j] += cnt[k][i + 1][j];
  int q, t, l, r;
  char c;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d %c", &l, &c);
      l--;
      int u = l / 2520;
      for (int i = u, j = l % 2520; i >= 0; i--)
        cnt[hgm(str[l])][i][j]--, cnt[hgm(c)][i][j]++;
      str[l] = c;
    } else {
      scanf("%d%d%s", &l, &r, s);
      l--, r--;
      int len = strlen(s);
      int n1 = l / 2520, n2 = r / 2520;
      int ans = 0;
      for (int i = 0, k = len - l % 2520 % len; i < 2520; i++, k++) {
        st[i] = l / 2520, ed[i] = r / 2520;
        if (n1 * 2520 + i < l) st[i]++;
        if (n2 * 2520 + i > r) ed[i]--;
        if (k == len) k = 0;
        if (st[i] > ed[i]) continue;
        ans += cnt[hgm(s[k])][st[i]][i] - cnt[hgm(s[k])][ed[i] + 1][i];
      }
      cout << ans << endl;
    }
  }
  return 0;
}
