#include <bits/stdc++.h>
template <typename T>
struct ScanfSpecifier {};
template <>
struct ScanfSpecifier<char*> {
  static constexpr const char* value = "%s";
};
template <>
struct ScanfSpecifier<int> {
  static constexpr const char* value = "%d";
};
template <>
struct ScanfSpecifier<double> {
  static constexpr const char* value = "%lf";
};
template <>
struct ScanfSpecifier<float> {
  static constexpr const char* value = "%f";
};
template <>
struct ScanfSpecifier<char> {
  static constexpr const char* value = "%c";
};
template <>
struct ScanfSpecifier<const char*> {
  static constexpr const char* value = "%s";
};
template <>
struct ScanfSpecifier<unsigned long> {
  static constexpr const char* value = "%lu";
};
template <>
struct ScanfSpecifier<unsigned int> {
  static constexpr const char* value = "%u";
};
template <>
struct ScanfSpecifier<long long int> {
  static constexpr const char* value = "%lld";
};
template <typename T>
int RD(T& arg) {
  return std::scanf(ScanfSpecifier<T>::value, &arg);
}
template <int S>
int RD(char (&arg)[S]) {
  return std::scanf("%s", arg);
}
int RD(char* arg) { return std::scanf("%s", arg); }
template <>
int RD<char>(char& arg) {
  return std::scanf(" %c", &arg);
}
template <typename T, typename... Args>
int RD(T& arg1, Args&... args) {
  return RD(arg1) + RD(args...);
}
template <typename T>
T RD() {
  T ret;
  RD(ret);
  return ret;
}
template <typename It>
void RDV(It begin, It end) {
  while (begin != end) RD(*begin++);
}
template <typename C>
void RDV(C& c) {
  RDV(std::begin(c), std::end(c));
}
template <typename T>
void WT(T arg) {
  std::printf(ScanfSpecifier<T>::value, arg);
}
template <typename T, typename U>
void WT(std::pair<T, U> arg) {
  std::printf("(");
  WT(arg.first);
  std::printf(", ");
  WT(arg.second);
  std::printf(")");
}
template <typename... Args>
void WT(Args... args) {
  int alc = 0;
  int dummy[] = {((alc++ ? std::printf(" ") : 0), WT(args), 0)...};
}
template <typename... Args>
void WTL(Args... args) {
  WT(args...);
  std::printf("\n");
}
template <typename It>
void WTV(It begin, It end) {
  int alc = 0;
  while (begin != end) (alc++ ? std::printf(" ") : 0), WT(*begin++);
}
template <typename C>
void WTV(const C& c) {
  WTV(std::begin(c), std::end(c));
}
template <typename It>
void WTVL(It begin, It end) {
  WTV(begin, end);
  std::printf("\n");
}
template <typename C>
void WTVL(const C& c) {
  WTVL(std::begin(c), std::end(c));
}
struct Range {
  struct It {
    int num, step;
    int operator*() { return num; }
    void operator++() { num += step; }
    bool operator!=(const It& other) { return num != other.num; }
  };
  Range(int ee) : b(0), e(ee) {}
  Range(int bb, int ee) : b(bb), e(ee) {}
  It begin() { return {b, (b < e ? 1 : -1)}; }
  It end() { return {e, 0}; }
  int b, e;
};
template <typename T>
inline T& UMAX(T& x, T y) {
  if (x < y) x = y;
  return x;
}
template <typename T>
inline T& UMIN(T& x, T y) {
  if (y < x) x = y;
  return x;
}
template <typename T, typename... Args>
struct ArithmiticPromotion {
  typedef decltype(T() + typename ArithmiticPromotion<Args...>::type()) type;
};
template <typename T, typename U>
struct ArithmiticPromotion<T, U> {
  typedef decltype(T() + U()) type;
};
template <typename T>
struct ArithmiticPromotion<T, T> {};
template <typename T>
struct ArithmiticPromotion<T> {};
template <typename T, typename U>
typename ArithmiticPromotion<T, U>::T MAX(T a, U b) {
  return a < b ? b : a;
}
template <typename T, typename... Args>
typename ArithmiticPromotion<T, Args...>::T MAX(T a, Args... args) {
  return MAX(a, MAX(args...));
}
template <typename T, typename U>
typename ArithmiticPromotion<T, U>::T MIN(T a, U b) {
  return a < b ? a : b;
}
template <typename T, typename... Args>
typename ArithmiticPromotion<T, Args...>::T MIN(T a, Args... args) {
  return MIN(a, MIN(args...));
}
inline int CLZ(int n) { return __builtin_clz(n); }
inline int CLZLL(long long int n) { return __builtin_clzll(n); }
inline int CTZ(int n) { return __builtin_ctz(n); }
inline int CTZLL(long long int n) { return __builtin_ctzll(n); }
inline int POPCNT(int n) { return __builtin_popcount(n); }
inline int POPCNTLL(long long int n) { return __builtin_popcountll(n); }
namespace XX {
template <typename T>
class BinaryIndexedTree {
 public:
  BinaryIndexedTree() {}
  BinaryIndexedTree(int size) : _data(size + 1, 0) {}
  BinaryIndexedTree(int size, const T& val) : _data(size + 1, val) {}
  int lower_bound(T value) {
    if (!value) return 0;
    T cur = T();
    int cur_mask = 0;
    for (int mask = 1 << (31 - CLZ((int)_data.size() - 1)); mask; mask >>= 1)
      if ((cur_mask | mask) < _data.size() &&
          cur + _data[cur_mask | mask] < value)
        cur += _data[cur_mask |= mask];
    return cur_mask + (cur < value) - 1;
  }
  int lower_bound(int l, T value) {
    if (!value) return l;
    T v = query(l - 1);
    return lower_bound(value + query(l - 1));
  }
  template <typename U>
  void update(int idx, U updater) {
    idx++;
    while (idx < _data.size()) {
      updater(_data[idx]);
      idx += idx & -idx;
    }
  }
  void update(int idx, const T& val) {
    idx++;
    while (idx < _data.size()) {
      _data[idx] += val;
      idx += idx & -idx;
    }
  }
  template <typename F>
  void query(int idx, F agt) {
    idx++;
    while (idx > 0) {
      agt(_data[idx]);
      idx -= idx & -idx;
    }
  }
  template <typename F>
  void query(int l, int r, F agt) {
    while (r > 0) {
      agt(_data[r], 1);
      r -= r & -r;
    }
    while (l > 0) {
      agt(_data[l], -1);
      l -= l & -l;
    }
  }
  T query(int idx) {
    idx++;
    T ret = T();
    while (idx > 0) {
      ret += _data[idx];
      idx -= idx & -idx;
    }
    return ret;
  }
  T query(int l, int r) {
    T ret = T();
    while (r > 0) {
      ret += _data[r];
      r -= r & -r;
    }
    while (l > 0) {
      ret -= _data[l];
      l -= l & -l;
    }
    return ret;
  }

 private:
  std::vector<T> _data;
};
}  // namespace XX
template <typename T>
using BIT = XX::BinaryIndexedTree<T>;
using RG = Range;
using namespace std;
BIT<int> bit[4][11][11];
char S[100009];
int c2i(char c) {
  switch (c) {
    case 'A':
      return 0;
    case 'T':
      return 1;
    case 'G':
      return 2;
    default:
      return 3;
  }
}
int main() {
  RD(S);
  int N = strlen(S);
  for (int c : RG(4))
    for (int l : RG(1, 11))
      for (int m : RG(l)) bit[c][l][m] = BIT<int>((N + l - 1) / l);
  for (int i : RG(N)) {
    S[i] = c2i(S[i]);
    for (int l : RG(1, 11)) bit[S[i]][l][i % l].update(i / l, 1);
  }
  int Q;
  RD(Q);
  while (Q--) {
    int t;
    RD(t);
    if (t == 1) {
      int i;
      char c;
      RD(i, c);
      c = c2i(c);
      i--;
      if (S[i] == c) continue;
      for (int l : RG(1, 11)) {
        bit[S[i]][l][i % l].update(i / l, -1);
        bit[c][l][i % l].update(i / l, 1);
      }
      S[i] = c;
    } else {
      int l, r;
      char buf[32];
      RD(l, r, buf);
      l--, r--;
      int len = strlen(buf);
      int ans = 0;
      for (int i : RG(len)) {
        if (l + i > r) break;
        int m = (l + i) % len;
        ans += bit[c2i(buf[i])][len][m].query(
            (l + i) / len, (r - (l + i)) / len + (l + i) / len + 1);
      }
      WTL(ans);
    }
  }
}
