#include <bits/stdc++.h>
using namespace std;
int tree[4][11][11][100001];
int MaxVal = 100001;
void update(int d1, int d2, int d3, int idx, int val) {
  while (idx <= MaxVal) {
    tree[d1][d2][d3][idx] += val;
    idx += (idx & -idx);
  }
}
int read(int d1, int d2, int d3, int idx) {
  int sum = 0;
  while (idx > 0) {
    sum += tree[d1][d2][d3][idx];
    idx -= (idx & -idx);
  }
  return sum;
}
int main() {
  string str;
  memset(tree, 0, sizeof tree);
  cin >> str;
  for (int i = 1; i <= str.size(); i++) {
    for (int j = 1; j <= 10; j++) {
      if (str[i - 1] == 'A')
        update(0, j, i % j, i, 1);
      else if (str[i - 1] == 'T')
        update(1, j, i % j, i, 1);
      else if (str[i - 1] == 'G')
        update(2, j, i % j, i, 1);
      else if (str[i - 1] == 'C')
        update(3, j, i % j, i, 1);
    }
  }
  int n, one, two, three;
  char c;
  string temp;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> one;
    if (one == 1) {
      cin >> two;
      cin >> c;
      for (int j = 1; j <= 10; j++) {
        if (str[two - 1] == 'A')
          update(0, j, two % j, two, -1);
        else if (str[two - 1] == 'T')
          update(1, j, two % j, two, -1);
        else if (str[two - 1] == 'G')
          update(2, j, two % j, two, -1);
        else if (str[two - 1] == 'C')
          update(3, j, two % j, two, -1);
      }
      str[two - 1] = c;
      for (int j = 1; j <= 10; j++) {
        if (str[two - 1] == 'A')
          update(0, j, two % j, two, 1);
        else if (str[two - 1] == 'T')
          update(1, j, two % j, two, 1);
        else if (str[two - 1] == 'G')
          update(2, j, two % j, two, 1);
        else if (str[two - 1] == 'C')
          update(3, j, two % j, two, 1);
      }
    } else if (one == 2) {
      cin >> two >> three;
      cin >> temp;
      int total = 0;
      for (int j = 0; j < temp.size(); j++) {
        if (temp[j] == 'A')
          total += read(0, temp.size(), (j + two) % temp.size(), three) -
                   read(0, temp.size(), (j + two) % temp.size(), two - 1);
        else if (temp[j] == 'T')
          total += read(1, temp.size(), (j + two) % temp.size(), three) -
                   read(1, temp.size(), (j + two) % temp.size(), two - 1);
        else if (temp[j] == 'G')
          total += read(2, temp.size(), (j + two) % temp.size(), three) -
                   read(2, temp.size(), (j + two) % temp.size(), two - 1);
        else if (temp[j] == 'C')
          total += read(3, temp.size(), (j + two) % temp.size(), three) -
                   read(3, temp.size(), (j + two) % temp.size(), two - 1);
      }
      cout << total << "\n";
    }
  }
  return 0;
}
