#include <bits/stdc++.h>
using namespace std;
int st[56 * 4][101000];
char s[101000], mat[14];
int n, top;
int mark[11][11][200];
int Q;
void change(int p, char c, int sign) {
  for (int m = 1; m <= 10; m++) {
    int k = mark[m][p % m][c];
    for (int i = p; i <= n; i += ((i) & (-(i)))) st[k][i] += sign;
  }
}
int query(int m, int p, int L, int R, char c) {
  int k = mark[m][p][c];
  int ans = 0;
  for (int i = R; i; i -= ((i) & (-(i)))) ans += st[k][i];
  for (int i = L - 1; i; i -= ((i) & (-(i)))) ans -= st[k][i];
  return ans;
}
int main() {
  for (int i = 1; i <= 10; i++)
    for (int j = 0; j < i; j++) {
      mark[i][j]['A'] = ++top;
      mark[i][j]['C'] = ++top;
      mark[i][j]['G'] = ++top;
      mark[i][j]['T'] = ++top;
    }
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) change(i, s[i], 1);
  for (scanf("%d", &Q); Q; Q--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int p;
      scanf("%d ", &p);
      change(p, s[p], -1);
      scanf("%c", &s[p]);
      change(p, s[p], 1);
    } else {
      int L, R;
      scanf("%d %d %s", &L, &R, mat + 1);
      int m = strlen(mat + 1);
      int ans = 0;
      for (int i = 1; i <= m; i++) {
        ans += query(m, (L + i - 1) % m, L, R, mat[i]);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
