#include <bits/stdc++.h>
using namespace std;
const signed int inf = (signed)((1u << 31) - 1);
const signed long long llf = (signed long long)((1ull << 61) - 1);
const double eps = 1e-6;
const int binary_limit = 128;
template <typename T>
inline bool readInteger(T& u) {
  char x;
  int aFlag = 1;
  while (!isdigit((x = getchar())) && x != '-' && x != -1)
    ;
  if (x == -1) {
    ungetc(x, stdin);
    return false;
  }
  if (x == '-') {
    x = getchar();
    aFlag = -1;
  }
  for (u = x - '0'; isdigit((x = getchar())); u = (u << 1) + (u << 3) + x - '0')
    ;
  ungetc(x, stdin);
  u *= aFlag;
  return true;
}
int cti(char x) {
  if (x == 'A') return 0;
  if (x == 'C') return 1;
  if (x == 'G') return 2;
  return 3;
}
typedef class Chunk {
 public:
  int id;
  int counter[11][11][4];
  Chunk(){};
  Chunk(int id) : id(id) { memset(counter, 0, sizeof(counter)); }
} Chunk;
int n, m;
int cs, cc;
char s[100005];
vector<Chunk> lis;
inline void init() {
  gets(s);
  readInteger(n);
  m = strlen(s);
  cs = (int)sqrt(m + 0.5);
}
inline int disposeWithBeginning(int a, char* buf, int len) {
  int sid = a / cs, ret = 0;
  for (int i = a; i < (sid + 1) * cs; i++) {
    if (s[i] == buf[(i - a) % len]) ret++;
  }
  return ret;
}
inline int disposeWithEnding(int a, int b, char* buf, int len) {
  int eid = b / cs, ret = 0;
  for (int i = eid * cs; i <= b; i++) {
    if (s[i] == buf[(i - a) % len]) ret++;
  }
  return ret;
}
inline void init_chunks() {
  for (cc = 0; cc * cs <= m; cc++) {
    Chunk b(cc);
    for (int mod = 1; mod <= 10; mod++) {
      for (int rest = 0; rest < mod; rest++) {
        int start_pos = cc * cs - (cc * cs) % mod + rest;
        if (start_pos < cc * cs) start_pos += mod;
        for (int i = start_pos; i < (cc + 1) * cs; i += mod)
          b.counter[mod][rest][cti(s[i])]++;
      }
    }
    lis.push_back(b);
  }
}
inline void solve() {
  int opt, a, b, len, res;
  char buf[15];
  while (n--) {
    readInteger(opt);
    readInteger(a);
    a--;
    if (opt == 1) {
      scanf("%s", buf);
      int bid = a / cs;
      char bchar = s[a];
      for (int mod = 1; mod <= 10; mod++) {
        b = a % mod;
        lis[bid].counter[mod][b][cti(buf[0])]++,
            lis[bid].counter[mod][b][cti(bchar)]--;
      }
      s[a] = buf[0];
    } else {
      res = 0;
      readInteger(b);
      b--;
      scanf("%s", buf);
      len = strlen(buf);
      int sid = a / cs, eid = b / cs;
      if (sid == eid) {
        for (int i = a; i <= b; i++) {
          if (s[i] == buf[(i - a) % len]) res++;
        }
      } else {
        for (int i = sid + 1; i < eid; i++) {
          int base = (i * cs - a) % len;
          int rbase = (i * cs) % len;
          for (int j = 0; j < len; j++) {
            res += lis[i].counter[len][(rbase + j) % len]
                                 [cti(buf[(base + j) % len])];
          }
        }
        res += disposeWithBeginning(a, buf, len);
        res += disposeWithEnding(a, b, buf, len);
      }
      printf("%d\n", res);
    }
  }
}
int main() {
  init();
  init_chunks();
  solve();
  return 0;
}
