#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;

namespace Math {
    ll modpow(ll b, ll p, ll m) {
        ll r = 1;
        for (; p; p >>= 1, b = b * b % m)
            if (p & 1)
                r = r * b % m;
        return r;
    }

    ll modinv(ll b, ll m) { return modpow(b, m - 2, m); }

    // Least significant bit.
    ll lsb(ll x) { return x & (-x); }

    template <class T> const T inf() { return 0; }
    template <> const ll inf<ll>() { return 0x3f3f3f3f3f3f3f3fll; }
    template <> const int inf<int>() { return 0x3f3f3f3f; }

    template <class T> T gcd(T a, T b) { return abs(__gcd(a, b)); }
    template <class T> T clamp(T n, T l, T r) { return n < l ? l : n > r ? r : n; }
    template <class T> T lcm(T a, T b) { return abs(a / gcd(a, b) * b); }
    template <class T> T sgn(T n) { return n == 0 ? 0 : n > 0 ? 1 : -1; }

    // Generic modular integer.
    template<int MOD, typename IntType = int>
    struct GModint {
        IntType val;

        GModint() : val(0) {}

        GModint(int v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        GModint(ll v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        explicit operator bool() const { return val != 0; }

        const bool operator==(const GModint &g) const { return val == g.val; }

        const bool operator!=(const GModint &g) const { return val != g.val; }

        const GModint operator+=(const GModint &g) { return *this = *this + g; }

        const GModint operator-=(const GModint &g) { return *this = *this - g; }

        const GModint operator*=(const GModint &g) { return *this = *this * g; }

        const GModint operator/=(const GModint &g) { return *this = *this / g; }

        const GModint operator^=(const GModint &g) { return *this = *this ^ g; }

        const GModint operator-() const { return GModint(val == 0 ? 0 : MOD - val, true); }

        const GModint operator+(const GModint &g) const {
            ll newval = val + g.val;
            if (newval >= MOD)
                newval -= MOD;
            return GModint(newval, true);
        }

        const GModint operator-(const GModint &g) const { return *this + (-g); }

        const GModint operator*(const GModint &g) const { return GModint(1ll * val * g.val); }

        const GModint operator/(const GModint &g) const { return *this * g.inv(); }

        template<class T>
        const GModint operator^(const T t) const { return GModint(modpow(val, t, MOD)); }

        const GModint inv() const { return GModint(modinv(val, MOD)); }
    };

    using Modint = GModint<1000000007>;
}

int n, q;
bitset<26> segtree[2000005];
string s;

void build(int id, int l, int r) {
    if (l == r) {
        segtree[id][s[l] - 'a'] = true;
        return;
    }
    int m = l + r >> 1;
    build(id * 2, l, m);
    build(id * 2 + 1, m + 1, r);
    segtree[id] = segtree[id * 2] | segtree[id * 2 + 1];
}

void update(int id, int l, int r, int x, int v) {
    if (l == x && x == r) {
        segtree[id].reset();
        segtree[id][v] = true;
        return;
    }
    int m = l + r >> 1;
    if (x <= m)
        update(id * 2, l, m, x, v);
    else
        update(id * 2 + 1, m + 1, r, x, v);
    segtree[id] = segtree[id * 2] | segtree[id * 2 + 1];
}

bitset<26> query(int id, int l, int r, int ql, int qr) {
    if (l == ql && r == qr) {
        return segtree[id];
    }
    int m = l + r >> 1;
    if (qr <= m)
        return query(id * 2, l, m, ql, qr);
    else if (ql > m)
        return query(id * 2 + 1, m + 1, r, ql, qr);
    else
        return query(id * 2, l, m, ql, m) | query(id * 2 + 1, m + 1, r, m + 1, qr);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> s >> q;

    build(1, 0, s.length() - 1);

    for (int i = 0; i < q; i++) {
        int t; cin >> t;
        if (t == 1) {
            int i; char c; cin >> i >> c;
            update(1, 0, s.length() - 1, i - 1, int(c - 'a'));
        } else if (t == 2) {
            int l, r; cin >> l >> r;
            bitset<26> res = query(1, 0, s.length() - 1, l - 1, r - 1);
            cout << res.count() << endl;
        }
    }
}


Measured memory_bytes: 11292