#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f2f1f0f;
const long long LINF = 1ll * INF * INF;
const int MAX_N = 1e5 + 100, MAX_Q = 1e5 + 100;
map<char, int> Mp;
char S[MAX_N];
int Q;
int Nr[MAX_N], N;
struct IDX {
  int P;
  vector<int> val[4];
  IDX() {}
  IDX(int n) {
    for (P = 1; P < n; P <<= 1)
      ;
    val[0] = val[1] = val[2] = val[3] = vector<int>(2 * P, 0);
  }
  void update(int v, int k) {
    v += P;
    for (int l = 0; l < 4; l++) val[l][v] = 0;
    val[k][v] = 1;
    while (v >>= 1) {
      for (int l = 0; l < 4; l++) val[l][v] = val[l][v * 2] + val[l][v * 2 + 1];
    }
  }
  int getCnt(int a, int b, int k) {
    a += P;
    b += P;
    int res = 0;
    while (a <= b) {
      if (a % 2 == 1) res += val[k][a++];
      if (b % 2 == 0) res += val[k][b--];
      a >>= 1;
      b >>= 1;
    }
    return res;
  }
};
int main() {
  scanf("%s", S);
  N = strlen(S);
  for (int k = 0; k < 4; k++) Mp["ATGC"[k]] = k;
  for (int i = 0; i < N; i++) Nr[i] = Mp[S[i]];
  scanf("%d", &Q);
  IDX idx[12][12];
  for (int i = 1; i <= 10; i++)
    for (int j = 0; j < i; j++) idx[i][j] = IDX(N);
  for (int p = 1; p <= 10; p++)
    for (int r = 0; r < p; r++)
      for (int i = r; i < N; i += p) {
        idx[p][r].update(i, Nr[i]);
      }
  while (Q--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int x;
      char s[5];
      scanf("%d%s", &x, s);
      x--;
      Nr[x] = Mp[s[0]];
      for (int p = 1; p <= 10; p++) {
        int r = x % p;
        idx[p][r].update(x, Nr[x]);
      }
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      l--;
      r--;
      char s[15];
      scanf("%s", s);
      int n = strlen(s);
      int p = n;
      int ans = 0;
      for (int rr = 0; rr < n; rr++) {
        ans += idx[p][(l + rr) % p].getCnt(l, r, Mp[s[rr]]);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
