#include<bits/stdc++.h>
 
using namespace std;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define str string
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Forrev(i,s,e) for (ll i=(s); i>=(e); i--)
#define all(v) v.begin(),v.end()

#define vll vector<ll>
#define vs vector<string>
#define mapll map<ll,ll>
#define pll pair<ll,ll>
#define initialise(a, x) memset(a, x, sizeof(a))
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define int ll
#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
const ll mod=1e9 + 7;

ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

ll gcd(ll a, ll b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);        
}

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}


const int M = 5e5 + 1;
int arr[M], seg[4*M];
 
void build(int start, int end, int index)
{
    if (start == end)
    {
        seg[index] = arr[start];
        return;
    }
    int mid = (start+end)/2;
    build(start, mid, 2*index+1);
    build(mid+1, end, 2*index+2);
    seg[index] = (seg[2*index+1] | seg[2*index+2]);
}
 
void update(int start, int end, int l, int r, int index, int val)
{
 
    if (start > r or end < l)
        return;
    if(start==end and start==l)
    {
        seg[index]=val;
        return;
    }

    int mid = (start+end)/2;
    update(start, mid, l, r, 2*index+1, val);
    update(mid+1, end, l, r, 2*index+2, val);
    seg[index] = (seg[2*index+1] | seg[2*index+2]);
}
 
int query(int start, int end, int l, int r, int index)
{
 
    if (start > r or end < l)
        return 0;
 
    if (start >= l and end <= r)
        return seg[index];
 
    int mid = (start+end)/2;
    int a = query(start, mid, l, r, 2*index+1);
    int b = query(mid+1, end, l, r, 2*index+2);
    return (a | b);
}


void solve()
{
    int n;
    cin>>n;
    string s1;
    cin>>s1;
    For(i,0,n)
    {
        arr[i]=1LL<<(s1[i]-'a');
    }
    build(0,n-1,0);

    ll q;
    cin>>q;
    For(l,0,q)
    {
        int t1,a,b;
        cin>>t1;
        if(t1==1)
        {
            int a;
            cin>>a;
            char b;
            cin>>b;
            ll c=b-'a';
            update(0,n-1,a-1,a-1,0,(1LL<<c));
        }
        else
        {
            ll a,b;
            cin>>a>>b;
            ll temp=query(0,n-1,a-1,b-1,0);
            ll ans=0;
            For(i,0,26)
            {
                if((temp & (1LL<<i)))
                    ans++;
            }
            cout<<ans<<endl;
            
        }
    }
}

signed main() 
{
    fast_cin();
    // #ifndef ONLINE_JUDGE
    // freopen("C:/IO/in.txt", "r", stdin);
    // freopen("C:/IO/out.txt", "w", stdout);
    // #endif
    
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    
    
    return 0;    
}

Measured memory_bytes: 16412