#include <bits/stdc++.h>   using namespace std;   const long long neutral = 0;   class SegmentTree {     vector<long long> a;     int n;       public:     SegmentTree(long long* st, long long* en) {       int sz = int(en - st);       for (n = 1; n < sz; n <<= 1)         ;       a.assign(n << 1, neutral);       for (int i = 0; i < sz; i++) a[i + n] = st[i];       for (int i = n + sz - 1; i > 1; i--) a[i >> 1] = ((a[i >> 1]) | (a[i]));     }     void update(int i, long long x) {       a[i += n] = x;       for (i >>= 1; i; i >>= 1) a[i] = ((a[i << 1]) | (a[1 + (i << 1)]));     }     long long query(int l, int r) {       long long ans = neutral;       for (l += n, r += n + 1; l < r; l >>= 1, r >>= 1) {         if (l & 1) ans = ((ans) | (a[l++]));         if (r & 1) ans = ((ans) | (a[--r]));       }       return ans;     }   };   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     cin.exceptions(cin.failbit);     int n, q, m;     string s;     cin >> s;     n = (int)(s).size();     long long v[n];     for (int i = 0; i < (n); ++i) {       v[i] = 1LL << (s[i] -  a );     }     cin >> q;     SegmentTree st(v, v + n);     while (q--) {       int t;       cin >> t;       if (t == 2) {         int a, b;         cin >> a >> b;         long long res = st.query(a - 1, b - 1), c = 0;         while (res > 0) c++, res -= (res & -res);         cout << c << endl;       } else {         int a;         char c;         cin >> a >> c;         int b = c -  a ;         st.update(a - 1, 1LL << b);       }     }     return 0;   }   