#include <bits/stdc++.h>
using namespace std;
const int K = 2;
const double PI = acos(-1);
template <class T>
inline T bigmod(T a, T b, T M) {
  long long ret = 1;
  for (; b > 0; b >>= 1) {
    if (b & 1) ret = (ret * a) % M;
    a = (a * a) % M;
  }
  return ret;
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
template <class T>
inline T poww(T a, T b) {
  long long ret = 1;
  for (; b > 0; b >>= 1) {
    if (b & 1) ret = ret * a;
    a = a * a;
  }
  return (T)ret;
}
pair<int, int> exEuclid(int a, int b) {
  if (b == 0)
    return pair<int, int>(1, 0);
  else {
    pair<int, int> r = exEuclid(b, a % b);
    return pair<int, int>(r.second, r.first - r.second * (a / b));
  }
}
int modInv(int a, int m) {
  pair<int, int> ret = exEuclid(a, m);
  return ((ret.first % m) + m) % m;
}
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
string s, r;
int q, x, y, ty;
struct fenwick {
  int tree[100010];
  void update(int idx, int val, int n) {
    while (idx <= n) {
      tree[idx] += val;
      idx += idx & (-idx);
    }
  }
  int query(int idx) {
    int sum = 0;
    while (idx > 0) {
      sum += tree[idx];
      idx -= idx & (-idx);
    }
    return sum;
  }
};
fenwick arr[11][4][10];
int ret(char ch) {
  if (ch == 'A') return 0;
  if (ch == 'T') return 1;
  if (ch == 'G') return 2;
  if (ch == 'C') return 3;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> s;
  cin >> q;
  for (int i = (1); i <= (10); i++) {
    for (int p = (0); p < (s.size()); p++) {
      int v = ret(s[p]);
      arr[i][v][p % i].update(p + 1, 1, s.size());
    }
  }
  while (q--) {
    cin >> ty;
    if (ty == 1) {
      cin >> x >> r;
      int u = ret(s[x - 1]);
      int v = ret(r[0]);
      s[x - 1] = r[0];
      for (int i = (1); i <= (10); i++) {
        arr[i][u][(x - 1) % i].update(x, -1, s.size());
        arr[i][v][(x - 1) % i].update(x, 1, s.size());
      }
    } else {
      cin >> x >> y >> r;
      int ans = 0, p = r.size();
      for (int i = (0); i < (r.size()); i++) {
        ans += arr[p][ret(r[i])][(x - 1 + i) % p].query(y) -
               arr[p][ret(r[i])][(x - 1 + i) % p].query(x - 1);
      }
      cout << ans << endl;
    }
  }
  return 0;
}
