# https://atcoder.jp/contests/abc157/tasks/abc157_e

from string import ascii_lowercase
from bisect import bisect_left, insort
from collections import defaultdict

N = int(input())
S = list(input())
Q = int(input())

locs = {c: [] for c in ascii_lowercase}
for i in range(N):
    locs[S[i]].append(i + 1)

for _ in range(Q):
    qt, l, r = input().split()
    l = int(l)
    if int(qt) == 1:
        if S[l - 1] != r:
            locs[S[l - 1]].remove(l)
            S[l - 1] = r
            insort(locs[r], l)
    else:
        count = 0
        r = int(r)
        for ch in ascii_lowercase:
            if len(locs[ch]) > 0:
                left = bisect_left(locs[ch], l)
                if left != len(locs[ch]):
                    if locs[ch][left] <= r:
                        count += 1

        print(count) from string import ascii_lowercase from bisect import bisect_left, insort from collections import defaultdict N = int(input()) N int(input()) int input() input S = list(input()) S list(input()) list input() input Q = int(input()) Q int(input()) int input() input c: [] for c in ascii_lowercase for c in ascii_lowercase c ascii_lowercase for c in ascii_lowercase c [] locs = {c: [] for c in ascii_lowercase} locs {c: [] for c in ascii_lowercase} for i in range(N):
    locs[S[i]].append(i + 1) i range(N) range N locs[S[i]].append(i + 1) [S[i]].append [S[i]] locs S[i] S i append i + 1 i 1 for _ in range(Q):
    qt, l, r = input().split()
    l = int(l)
    if int(qt) == 1:
        if S[l - 1] != r:
            locs[S[l - 1]].remove(l)
            S[l - 1] = r
            insort(locs[r], l)
    else:
        count = 0
        r = int(r)
        for ch in ascii_lowercase:
            if len(locs[ch]) > 0:
                left = bisect_left(locs[ch], l)
                if left != len(locs[ch]):
                    if locs[ch][left] <= r:
                        count += 1

        print(count) _ range(Q) range Q qt, l, r = input().split() qt input().split() ().split () input split l r l = int(l) l int(l) int l if int(qt) == 1:
        if S[l - 1] != r:
            locs[S[l - 1]].remove(l)
            S[l - 1] = r
            insort(locs[r], l)
    else:
        count = 0
        r = int(r)
        for ch in ascii_lowercase:
            if len(locs[ch]) > 0:
                left = bisect_left(locs[ch], l)
                if left != len(locs[ch]):
                    if locs[ch][left] <= r:
                        count += 1

        print(count) int(qt) == 1 int(qt) int qt 1 if S[l - 1] != r:
            locs[S[l - 1]].remove(l)
            S[l - 1] = r
            insort(locs[r], l)
     S[l - 1] != r S[l - 1] S l - 1 l 1 r locs[S[l - 1]].remove(l) [S[l - 1]].remove [S[l - 1]] locs S[l - 1] S l - 1 l 1 remove l S[l - 1] = r S[l - 1] S l - 1 l 1 r insort(locs[r], l) insort locs[r] locs r l count = 0 count 0 r = int(r) r int(r) int r for ch in ascii_lowercase:
            if len(locs[ch]) > 0:
                left = bisect_left(locs[ch], l)
                if left != len(locs[ch]):
                    if locs[ch][left] <= r:
                        count += 1

         ch ascii_lowercase if len(locs[ch]) > 0:
                left = bisect_left(locs[ch], l)
                if left != len(locs[ch]):
                    if locs[ch][left] <= r:
                        count += 1

         len(locs[ch]) > 0 len(locs[ch]) len locs[ch] locs ch 0 left = bisect_left(locs[ch], l) left bisect_left(locs[ch], l) bisect_left locs[ch] locs ch l if left != len(locs[ch]):
                    if locs[ch][left] <= r:
                        count += 1

         left != len(locs[ch]) left len(locs[ch]) len locs[ch] locs ch if locs[ch][left] <= r:
                        count += 1

         locs[ch][left] <= r locs[ch][left] [ch] locs ch left r count += 1 count 1 print(count) print count l = int(l) int(l) l count += 1 1 count count = 0 0 count r = input().split() input().split() r N = int(input()) int(input()) N left = bisect_left(locs[ch], l) bisect_left(locs[ch], l) left qt, l, r = input().split() input().split() qt l, r = input().split() input().split() l r = int(r) int(r) r locs = {c: [] for c in ascii_lowercase} {c: [] for c in ascii_lowercase} locs Q = int(input()) int(input()) Q S = list(input()) list(input()) S
# https://atcoder.jp/contests/abc157/tasks/abc157_e

from string import ascii_lowercase
from bisect import bisect_left, insort
from collections import defaultdict

N = int(input())
S = list(input())
Q = int(input())

locs = {c: [] for c in ascii_lowercase}
for i in range(N):
    locs[S[i]].append(i + 1)

for _ in range(Q):
    qt, l, r = input().split()
    l = int(l)
    if int(qt) == 1:
        if S[l - 1] != r:
            locs[S[l - 1]].remove(l)
            S[l - 1] = r
            insort(locs[r], l)
    else:
        count = 0
        r = int(r)
        for ch in ascii_lowercase:
            if len(locs[ch]) > 0:
                left = bisect_left(locs[ch], l)
                if left != len(locs[ch]):
                    if locs[ch][left] <= r:
                        count += 1

        print(count)