import bisect

n = int(input())
s = list(input())
q = int(input())

pos = [[] for i in range(26)]
alp = "abcdefghijklmnopqrstuvwxyz"
atoi = {}
for i in range(26):
    atoi[alp[i]] = i
for i in range(n):
    pos[atoi[s[i]]].append(i)

for i in range(q):
    a, b, c = input().split()
    if a == "1":
        b = int(b)-1
        if c == s[b]:
            continue
        index = bisect.bisect_left(pos[atoi[s[b]]], b)
        del pos[atoi[s[b]]][index]
        bisect.insort_left(pos[atoi[c]], b)
        s[b] = c
    else:
        l, r = int(b)-1, int(c)
        ans = 0
        for i in range(26):
            cnt = bisect.bisect_left(pos[i], r) - bisect.bisect_left(pos[i], l)
            if cnt > 0:
                ans += 1
        print(ans) import bisect bisect 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 [] for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) [] pos = [[] for i in range(26)] pos [[] for i in range(26)] alp = "abcdefghijklmnopqrstuvwxyz" alp "abcdefghijklmnopqrstuvwxyz" atoi = {} atoi {} for i in range(26):
    atoi[alp[i]] = i i range(26) range 26 atoi[alp[i]] = i atoi[alp[i]] atoi alp[i] alp i i for i in range(n):
    pos[atoi[s[i]]].append(i) i range(n) range n pos[atoi[s[i]]].append(i) [atoi[s[i]]].append [atoi[s[i]]] pos atoi[s[i]] atoi s[i] s i append i for i in range(q):
    a, b, c = input().split()
    if a == "1":
        b = int(b)-1
        if c == s[b]:
            continue
        index = bisect.bisect_left(pos[atoi[s[b]]], b)
        del pos[atoi[s[b]]][index]
        bisect.insort_left(pos[atoi[c]], b)
        s[b] = c
    else:
        l, r = int(b)-1, int(c)
        ans = 0
        for i in range(26):
            cnt = bisect.bisect_left(pos[i], r) - bisect.bisect_left(pos[i], l)
            if cnt > 0:
                ans += 1
        print(ans) i range(q) range q a, b, c = input().split() a input().split() ().split () input split b c if a == "1":
        b = int(b)-1
        if c == s[b]:
            continue
        index = bisect.bisect_left(pos[atoi[s[b]]], b)
        del pos[atoi[s[b]]][index]
        bisect.insort_left(pos[atoi[c]], b)
        s[b] = c
    else:
        l, r = int(b)-1, int(c)
        ans = 0
        for i in range(26):
            cnt = bisect.bisect_left(pos[i], r) - bisect.bisect_left(pos[i], l)
            if cnt > 0:
                ans += 1
        print(ans) a == "1" a "1" b = int(b)-1 b int(b)-1 int(b) int b 1 if c == s[b]:
            continue
         c == s[b] c s[b] s b continue index = bisect.bisect_left(pos[atoi[s[b]]], b) index bisect.bisect_left(pos[atoi[s[b]]], b) bisect.bisect_left bisect bisect_left pos[atoi[s[b]]] pos atoi[s[b]] atoi s[b] s b b del pos[atoi[s[b]]][index] pos[atoi[s[b]]][index] [atoi[s[b]]] pos atoi[s[b]] atoi s[b] s b index bisect.insort_left(pos[atoi[c]], b) bisect.insort_left bisect insort_left pos[atoi[c]] pos atoi[c] atoi c b s[b] = c s[b] s b c l, r = int(b)-1, int(c) l int(b)-1 int(b) int b 1 r int(c) int c ans = 0 ans 0 for i in range(26):
            cnt = bisect.bisect_left(pos[i], r) - bisect.bisect_left(pos[i], l)
            if cnt > 0:
                ans += 1
         i range(26) range 26 cnt = bisect.bisect_left(pos[i], r) - bisect.bisect_left(pos[i], l) cnt bisect.bisect_left(pos[i], r) - bisect.bisect_left(pos[i], l) bisect.bisect_left(pos[i], r) bisect.bisect_left bisect bisect_left pos[i] pos i r bisect.bisect_left(pos[i], l) bisect.bisect_left bisect bisect_left pos[i] pos i l if cnt > 0:
                ans += 1
         cnt > 0 cnt 0 ans += 1 ans 1 print(ans) print ans ans = 0 0 ans r = int(b)-1, int(c) int(c) r b = int(b)-1 int(b)-1 b l, r = int(b)-1, int(c) int(b)-1 l c = input().split() input().split() c cnt = bisect.bisect_left(pos[i], r) - bisect.bisect_left(pos[i], l) bisect.bisect_left(pos[i], r) - bisect.bisect_left(pos[i], l) cnt s = list(input()) list(input()) s q = int(input()) int(input()) q pos = [[] for i in range(26)] [[] for i in range(26)] pos a, b, c = input().split() input().split() a b, c = input().split() input().split() b atoi = {} {} atoi n = int(input()) int(input()) n ans += 1 1 ans index = bisect.bisect_left(pos[atoi[s[b]]], b) bisect.bisect_left(pos[atoi[s[b]]], b) index alp = "abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz" alp
import bisect

n = int(input())
s = list(input())
q = int(input())

pos = [[] for i in range(26)]
alp = "abcdefghijklmnopqrstuvwxyz"
atoi = {}
for i in range(26):
    atoi[alp[i]] = i
for i in range(n):
    pos[atoi[s[i]]].append(i)

for i in range(q):
    a, b, c = input().split()
    if a == "1":
        b = int(b)-1
        if c == s[b]:
            continue
        index = bisect.bisect_left(pos[atoi[s[b]]], b)
        del pos[atoi[s[b]]][index]
        bisect.insort_left(pos[atoi[c]], b)
        s[b] = c
    else:
        l, r = int(b)-1, int(c)
        ans = 0
        for i in range(26):
            cnt = bisect.bisect_left(pos[i], r) - bisect.bisect_left(pos[i], l)
            if cnt > 0:
                ans += 1
        print(ans)