#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
const long long mod2 = 998244353;
const long double eps = 1e-10;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T>
struct BinaryIndexedTree {
  vector<T> data;
  BinaryIndexedTree(int sz) { data.assign(++sz, 0); }
  T sum(int k) {
    T ret = 0;
    for (++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }
  void add(int k, T x) {
    for (++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<vector<BinaryIndexedTree<int>>>> BIT(
      11,
      vector<vector<BinaryIndexedTree<int>>>(
          10, vector<BinaryIndexedTree<int>>(4, BinaryIndexedTree<int>(n))));
  string AGTC = "AGTC";
  map<char, int> mp = {{'A', 0}, {'G', 1}, {'T', 2}, {'C', 3}};
  for (int i = (int)(0); i < (int)(11); i++) {
    for (int j = (int)(0); j < (int)(i); j++) {
      for (int k = (int)(0); k < (int)(4); k++) {
        for (int l = j; l < n; l += i) {
          if (s[l] == AGTC[k]) {
            BIT[i][j][k].add(l, 1);
          }
        }
      }
    }
  }
  int q;
  cin >> q;
  for (int _ = (int)(0); _ < (int)(q); _++) {
    int t;
    cin >> t;
    if (t == 1) {
      int x;
      char c;
      cin >> x >> c;
      x--;
      char now = s[x];
      for (int i = (int)(0); i < (int)(11); i++)
        for (int j = (int)(0); j < (int)(i); j++) {
          if ((x - j) % i == 0) {
            BIT[i][j][mp[now]].add(x, -1);
            BIT[i][j][mp[c]].add(x, 1);
          }
        }
      s[x] = c;
    } else {
      int l, r;
      string e;
      cin >> l >> r >> e;
      l--;
      int ans = 0;
      for (int i = (int)(0); i < (int)(e.size()); i++) {
        if (l + i <= r) {
          ans += (BIT[e.size()][(l + i) % e.size()][mp[e[i]]].sum(r - 1) -
                  (l + i == 0 ? 0
                              : BIT[e.size()][(l + i) % e.size()][mp[e[i]]].sum(
                                    l + i - 1)));
        }
      }
      cout << ans << '\n';
    }
  }
  return 0;
}
