#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s, t;
  cin >> n >> s >> q;
  int count = 0;
  vector<int> a(q);
  vector<int> i(q);
  vector<char> c(q);
  for (int j = 0; j < q; j++) {
    cin >> a[j] >> i[j] >> c[j];
  }
  for (int l = 0; l < q; l++) {
    if (a[l] == 1) {
      if (s[l - 1] != c[l]) s[l - 1] = c[l];
    }
    if (a[l] == 2) {
      t = s.substr(i[l], ((int)(c[l] - '0')) - i[l] + 1);
      sort(s.begin(), s.end());
      for (int k = 1; k < t.size(); k++) {
        if (t[k] != t[k - 1]) count++;
        cout << count << endl;
      }
    }
  }
}
