// https://codeforces.com/contest/1234/problem/D

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vld vector < ld >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < long , long >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

string vow = "aeiou";
string s ;

vi v ;
int indx ;
int val ;

int mask = 0 ;
int l , r ;

int act_bits ( int n )
{
    int act = 0 ;
    while ( n )
    {
        act ++ ;
        n &= ( n-1 ) ;
    }
    return act ;
}

void prop ( int node )
{
    v[node] = v[2*node + 1] | v[2*node + 2] ;
}

void build ( int node , int start , int end )
{
    if ( start == end )
    {
        v[node] |= 1 << (s[start] - 'a') ;
        return ;
    }

    int mid = start + end >> 1 ;

    build ( 2*node + 1 , start , mid ) ;
    build ( 2*node + 2 , mid+1 , end ) ;

    prop ( node ) ;
}

void update ( int node , int start , int end )
{
    if ( start == end )
    {
        v[node] = val ;
        s[indx] = char ( val + 97 ) ;
        return ;
    }

    int mid = start + end >> 1 ;

    if ( start <= indx && indx <= mid )
        update ( 2*node + 1 , start , mid ) ;
    else
        update ( 2*node + 2 , mid+1 , end ) ;

    prop ( node ) ;
}

void query ( int node , int start , int end )
{
    if ( start > r || end < l ) return ;
    if ( start >= l && end <= r ) { mask |= v[node] ; return ; }

    int mid = start + end >> 1 ;

    query ( 2*node + 1 , start , mid ) ;
    query ( 2*node + 2 , mid+1 , end ) ;
}

void solve ( int test_case )
{
    int n ; cin >> n ;
    cin >> s ;

    v.resize ( 4*n ) ;
    build ( 0 , 0 , n-1 ) ;

    int q ; cin >> q ;

    while ( q-- )
    {
        int t ; cin >> t ;

        if ( t == 1 )
        {
            cin >> indx ; indx -- ;
            char c ; cin >> c ;
            val = 1 << (c - 'a') ;

            update ( 0 , 0 , n-1 ) ;
            C ;
        }

        cin >> l >> r ;
        l-- ; r-- ;
        mask = 0 ;

        query ( 0 , 0 , n-1 ) ;
        cout << act_bits ( mask ) << "\n" ;
    }

}

int main()
{
    fast
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 8732