#include <bits/stdc++.h>
using namespace std;
int LSOne(int x) { return x & (-x); }
struct FT {
  vector<int> v;
  FT(int n = 100000) { v.assign(n + 1, 0); }
  int rsq(int b) {
    int sum = 0;
    for (; b > 0; b -= LSOne(b)) {
      sum += v[b];
    }
    return sum;
  }
  int rsq(int a, int b) { return rsq(b) - (a > 1 ? rsq(a - 1) : 0); }
  void adjust(int k, int x) {
    for (; k < v.size(); k += LSOne(k)) {
      v[k] += x;
    }
  }
};
int main() {
  string s;
  cin >> s;
  int len = s.size();
  unordered_map<char, unordered_map<short, unordered_map<short, FT>>> d;
  for (int i = 0; i < len; i++) {
    for (int mod = 1; mod <= 10; mod++) {
      int rem = i % mod;
      d[s[i]][mod][rem].adjust(i + 1, 1);
    }
  }
  int q;
  cin >> q;
  for (int qq = 0; qq < q; qq++) {
    int kind;
    cin >> kind;
    if (kind == 1) {
      int x;
      string c;
      cin >> x >> c;
      for (int mod = 1; mod <= 10; mod++) {
        int rem = (x - 1) % mod;
        d[s[x - 1]][mod][rem].adjust(x, -1);
      }
      for (int mod = 1; mod <= 10; mod++) {
        int rem = (x - 1) % mod;
        d[c[0]][mod][rem].adjust(x, +1);
      }
      s[x - 1] = c[0];
    } else {
      int l, r;
      string e;
      cin >> l >> r >> e;
      int mod = e.size();
      int rem = (l - 1) % mod;
      int sum = 0;
      for (int i = 0; i < e.size(); i++) {
        sum += d[e[i]][mod][(rem + i) % mod].rsq(l, r);
      }
      cout << sum << endl;
    }
  }
}
