#include <bits/stdc++.h>
using namespace std;
static inline void canhazfast() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
  T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
  while (b) {
    T q = a / b;
    a %= b;
    swap(a, b);
    x0 -= q * x1;
    swap(x0, x1);
    y0 -= q * y1;
    swap(y0, y1);
  }
  x = x0;
  y = y0;
  return a;
}
static inline int ctz(unsigned x) { return __builtin_ctz(x); }
static inline int ctzll(unsigned long long x) { return __builtin_ctzll(x); }
static inline int clz(unsigned x) { return __builtin_clz(x); }
static inline int clzll(unsigned long long x) { return __builtin_clzll(x); }
static inline int popcnt(unsigned x) { return __builtin_popcount(x); }
static inline int popcntll(unsigned long long x) {
  return __builtin_popcountll(x);
}
static inline int bsr(unsigned x) { return 31 ^ clz(x); }
static inline int bsrll(unsigned long long x) { return 63 ^ clzll(x); }
struct BIT {
  int a[100016];
  void add(int i, int n, int d) {
    for (; i <= n; i += i & -i) a[i] += d;
  }
  int get(int i) {
    int res = 0;
    for (; i; i -= i & -i) res += a[i];
    return res;
  }
  int get(int l, int r) { return get(r) - get(l); }
};
BIT pref[4][10][10];
int main() {
  canhazfast();
  static char s[100016];
  static int a[100016];
  const map<char, int> dic = {{'A', 0}, {'C', 1}, {'G', 2}, {'T', 3}};
  int n, q;
  cin >> s;
  n = strlen(s);
  for (int i = 0; i < n; ++i) {
    a[i] = dic.at(s[i]);
    for (int m = 1; m <= 10; ++m) {
      int r = i % m;
      pref[a[i]][m - 1][r].add(i + 1, n, 1);
    }
  }
  cin >> q;
  for (; q; --q) {
    char e[16];
    int t, l, r, x;
    cin >> t;
    if (t == 1) {
      cin >> x;
      cin >> s[x - 1];
      int v = dic.at(s[x - 1]);
      for (int m = 1; m <= 10; ++m) {
        int r = (x - 1) % m;
        pref[a[x - 1]][m - 1][r].add(x, n, -1);
        pref[v][m - 1][r].add(x, n, 1);
      }
      a[x - 1] = v;
    } else {
      cin >> l >> r >> e;
      --l;
      int m = strlen(e);
      int ans = 0;
      for (int i = 0; i < m; ++i) {
        int re = (l + i) % m;
        int v = dic.at(e[i]);
        ans += pref[v][m - 1][re].get(l, r);
      }
      cout << ans << '\n';
    }
  }
  return 0;
}
