#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int t[4][11][11][N];
int n;
string s;
int val[256];
void insert(int val, int quo, int rem, int idx, int delta) {
  while (idx < N) {
    t[val][quo][rem][idx] += delta;
    idx += idx & -idx;
  }
}
int query(int val, int quo, int rem, int idx) {
  int res = 0;
  while (idx) {
    res += t[val][quo][rem][idx];
    idx -= idx & -idx;
  }
  return res;
}
void build() {
  memset(t, 0, sizeof t);
  val['A'] = 1;
  val['G'] = 2;
  val['C'] = 3;
  val['T'] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) {
      insert(val[s[i - 1]], j, i % j, i, 1);
    }
  }
}
int main() {
  cin >> s;
  n = s.length();
  build();
  int q;
  cin >> q;
  while (q--) {
    int type;
    cin >> type;
    if (type == 1) {
      int idx;
      char x;
      cin >> idx >> x;
      for (int i = 1; i <= 10; i++) {
        int quo = i;
        int rem = idx % i;
        insert(val[s[idx - 1]], quo, rem, idx, -1);
        insert(val[x], quo, rem, idx, 1);
      }
      s[idx - 1] = x;
    } else if (type == 2) {
      int l;
      int r;
      string e;
      cin >> l >> r >> e;
      int res = 0;
      l, r;
      for (int i = 0; i < e.length(); i++) {
        int rem = (l + i) % e.length();
        int quo = e.length();
        res += query(val[e[i]], quo, rem, r);
        res -= query(val[e[i]], quo, rem, l - 1);
      }
      cout << res << '\n';
    }
  }
}
