#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433832795l;
template <typename T>
inline auto sqr(T x) -> decltype(x * x) {
  return x * x;
}
template <typename T1, typename T2>
inline bool umx(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool umn(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int K = 1000;
const int N = 100100;
pair<char, int> ch[K];
int kolch;
int add[N][10][4];
string s, olds;
int n;
const char C[4] = {'A', 'T', 'G', 'C'};
char num[26];
void rebuild() {
  for (int i = int(0); i < int(kolch); ++i) {
    s[ch[i].second] = ch[i].first;
  }
  kolch = 0;
  olds = s;
  for (int i = int(n) - 1; i >= int(0); --i) {
    for (int j = int(0); j < int(10); ++j) {
      if (i + j + 1 < n) {
        for (int k = int(0); k < int(4); ++k) {
          add[i][j][k] = add[i + j + 1][j][k];
        }
      } else {
        for (int k = int(0); k < int(4); ++k) add[i][j][k] = 0;
      }
      add[i][j][num[s[i] - 'A']]++;
    }
  }
}
int main() {
  cout.setf(ios::showpoint | ios::fixed);
  std::ios_base::sync_with_stdio(false);
  cout.precision(20);
  memset(num, -1, sizeof(num));
  for (int i = int(0); i < int(4); ++i) num[C[i] - 'A'] = i;
  getline(cin, s);
  n = ((int)(s).size());
  int q;
  cin >> q;
  kolch = 0;
  rebuild();
  for (int i = int(0); i < int(q); ++i) {
    int tp;
    cin >> tp;
    if (tp == 1) {
      if (kolch == K) {
        rebuild();
      }
      int pos;
      char c;
      cin >> pos >> c;
      pos--;
      ch[kolch++] = make_pair(c, pos);
    } else {
      int l, r;
      string e;
      cin >> l >> r >> e;
      l--, r--;
      int ans = 0;
      for (int j = int(0); j < int(min((int)e.size(), r - l + 1)); ++j) {
        ans += add[l + j][((int)(e).size()) - 1][num[e[j] - 'A']];
        int diff = r - (l + j);
        int idx = (diff / (((int)(e).size())) + 1) * ((int)(e).size());
        ;
        ans -= add[idx + l + j][((int)(e).size()) - 1][num[e[j] - 'A']];
      }
      for (int j = int(0); j < int(kolch); ++j) {
        if (ch[j].second > r || ch[j].second < l) continue;
        if (s[ch[j].second] == e[(ch[j].second - l) % ((int)(e).size())]) ans--;
        s[ch[j].second] = ch[j].first;
        ;
        if (s[ch[j].second] == e[(ch[j].second - l) % ((int)(e).size())]) ans++;
      }
      for (int j = int(0); j < int(kolch); ++j) {
        s[ch[j].second] = olds[ch[j].second];
      }
      cout << ans << endl;
    }
  }
  return 0;
}
