#include <bits/stdc++.h>
using std::cerr;
using std::endl;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = 100005;
int n, q, a[MAXN], bit[4][11][10][MAXN];
char s[MAXN], t[11];
inline int trans(char ch) {
  if (ch == 'A')
    return 0;
  else if (ch == 'T')
    return 1;
  else if (ch == 'G')
    return 2;
  else
    return 3;
}
inline void add(int *Bit, int x, int kk) {
  for (int i = x; i <= n; i += ((i) & (-(i)))) Bit[i] += kk;
}
inline int ask(int *Bit, int x) {
  int ret = 0;
  for (int i = x; i; i -= ((i) & (-(i)))) ret += Bit[i];
  return ret;
}
inline int ask(int *Bit, int l, int r) { return ask(Bit, r) - ask(Bit, l - 1); }
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = (1); i <= (n); ++i) {
    a[i] = trans(s[i]);
    for (int j = (1); j <= (10); ++j) add(bit[a[i]][j][i % j], i, 1);
  }
  q = read();
  while (q--) {
    int opt = read();
    if (opt == 1) {
      int x = read();
      char ch = getchar();
      while (!isalpha(ch)) ch = getchar();
      int y = trans(ch);
      for (int j = (1); j <= (10); ++j) add(bit[a[x]][j][x % j], x, -1);
      a[x] = y;
      for (int j = (1); j <= (10); ++j) add(bit[a[x]][j][x % j], x, 1);
    } else {
      int l = read(), r = read();
      scanf("%s", t + 1);
      int len = strlen(t + 1), ans = 0;
      for (int j = (1); j <= (len); ++j)
        ans += ask(bit[trans(t[j])][len][(l + j - 1) % len], l, r);
      printf("%d\n", ans);
    }
  }
  return 0;
}
