#include <bits/stdc++.h>
using namespace std;
inline int f(char x) {
  switch (x) {
    case 'A':
      return 0;
    case 'T':
      return 1;
    case 'G':
      return 2;
    case 'C':
      return 3;
  }
  exit(-1);
}
const int N = 1e5 + 55;
int tree[4][11][11][N];
void update(int tp, int st, int gp, int pos, int v) {
  for (pos = N - pos - 5; pos < N; pos += pos & -pos) {
    tree[tp][st][gp][pos] += v;
  }
}
int getsum(int tp, int st, int gp, int pos) {
  int res = 0;
  for (pos = N - pos - 5; pos; pos -= pos & -pos) {
    res += tree[tp][st][gp][pos];
  }
  return res;
}
char s[N];
int n;
void init() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int st = 1; st <= 10; ++st) {
    for (int gp = 1; gp <= 10; ++gp) {
      for (int i = st; i <= n; i += gp) {
        update(f(s[i]), st, gp, i, 1);
      }
    }
  }
}
int findst(int gp, int pos) {
  pos %= gp;
  if (pos == 0) pos += gp;
  return pos;
}
int main(int args, const char* argv[]) {
  init();
  int q;
  scanf("%d", &q);
  int t, a, b;
  char tmp[15];
  while (q--) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d %s", &a, tmp);
      int pref = f(s[a]);
      int nf = f(tmp[0]);
      for (int gp = 1; gp <= 10; ++gp) {
        int st = findst(gp, a);
        update(pref, st, gp, a, -1);
        update(nf, st, gp, a, 1);
      }
      s[a] = tmp[0];
    } else {
      scanf("%d %d %s", &a, &b, tmp);
      int len = strlen(tmp), ans = 0;
      for (int i = 0; i < len; ++i) {
        int st = findst(len, a + i);
        ans += getsum(f(tmp[i]), st, len, a + i);
      }
      b += 1;
      for (int i = 0; i < len; ++i) {
        int st = findst(len, b + i);
        ans -= getsum(f(tmp[(i + b - a) % len]), st, len, b + i);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
