import sys
from bisect import bisect_left, bisect_right, insort

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = list('-' + sr())
d = [[] for _ in range(26)]
for i in range(1, N+1):
    s = S[i]
    o = ord(s) - ord('a')
    d[o].append(i)

Q = ir()
for _ in range(Q):
    q, a, b = sr().split()
    if q == '1':
        a = int(a)
        if S[a] == b:
            continue
        prev = ord(S[a]) - ord('a')
        d[prev].pop(bisect_left(d[prev], a))
        next = ord(b) - ord('a')
        insort(d[next], a)
        S[a] = b
    else:
        a = int(a); b = int(b)
        ans = 0
        for alpha in range(26):
            if bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1:
                ans += 1
        print(ans) import sys sys from bisect import bisect_left, bisect_right, insort sr = lambda: sys.stdin.readline().rstrip() sr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split N = ir() N ir() ir S = list('-' + sr()) S list('-' + sr()) list '-' + sr() '-' sr() sr [] for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [] d = [[] for _ in range(26)] d [[] for _ in range(26)] for i in range(1, N+1):
    s = S[i]
    o = ord(s) - ord('a')
    d[o].append(i) i range(1, N+1) range 1 N+1 N 1 s = S[i] s S[i] S i o = ord(s) - ord('a') o ord(s) - ord('a') ord(s) ord s ord('a') ord 'a' d[o].append(i) [o].append [o] d o append i Q = ir() Q ir() ir for _ in range(Q):
    q, a, b = sr().split()
    if q == '1':
        a = int(a)
        if S[a] == b:
            continue
        prev = ord(S[a]) - ord('a')
        d[prev].pop(bisect_left(d[prev], a))
        next = ord(b) - ord('a')
        insort(d[next], a)
        S[a] = b
    else:
        a = int(a); b = int(b)
        ans = 0
        for alpha in range(26):
            if bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1:
                ans += 1
        print(ans) _ range(Q) range Q q, a, b = sr().split() q sr().split() ().split () sr split a b if q == '1':
        a = int(a)
        if S[a] == b:
            continue
        prev = ord(S[a]) - ord('a')
        d[prev].pop(bisect_left(d[prev], a))
        next = ord(b) - ord('a')
        insort(d[next], a)
        S[a] = b
    else:
        a = int(a); b = int(b)
        ans = 0
        for alpha in range(26):
            if bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1:
                ans += 1
        print(ans) q == '1' q '1' a = int(a) a int(a) int a if S[a] == b:
            continue
         S[a] == b S[a] S a b continue prev = ord(S[a]) - ord('a') prev ord(S[a]) - ord('a') ord(S[a]) ord S[a] S a ord('a') ord 'a' d[prev].pop(bisect_left(d[prev], a)) [prev].pop [prev] d prev pop bisect_left(d[prev], a) bisect_left d[prev] d prev a next = ord(b) - ord('a') next ord(b) - ord('a') ord(b) ord b ord('a') ord 'a' insort(d[next], a) insort d[next] d next a S[a] = b S[a] S a b a = int(a) a int(a) int a b = int(b) b int(b) int b ans = 0 ans 0 for alpha in range(26):
            if bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1:
                ans += 1
         alpha range(26) range 26 if bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1:
                ans += 1
         bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1 bisect_right(d[alpha], b) - bisect_left(d[alpha], a) bisect_right(d[alpha], b) bisect_right d[alpha] d alpha b bisect_left(d[alpha], a) bisect_left d[alpha] d alpha a 1 ans += 1 ans 1 print(ans) print ans o = ord(s) - ord('a') ord(s) - ord('a') o q, a, b = sr().split() sr().split() q a = int(a) int(a) a ans += 1 1 ans b = sr().split() sr().split() b b = int(b) int(b) b d = [[] for _ in range(26)] [[] for _ in range(26)] d Q = ir() ir() Q lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr N = ir() ir() N a, b = sr().split() sr().split() a a = int(a) int(a) a ir = lambda: int(sr()) lambda: int(sr()) ir s = S[i] S[i] s sr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() sr next = ord(b) - ord('a') ord(b) - ord('a') next S = list('-' + sr()) list('-' + sr()) S prev = ord(S[a]) - ord('a') ord(S[a]) - ord('a') prev ans = 0 0 ans
import sys
from bisect import bisect_left, bisect_right, insort

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = list('-' + sr())
d = [[] for _ in range(26)]
for i in range(1, N+1):
    s = S[i]
    o = ord(s) - ord('a')
    d[o].append(i)

Q = ir()
for _ in range(Q):
    q, a, b = sr().split()
    if q == '1':
        a = int(a)
        if S[a] == b:
            continue
        prev = ord(S[a]) - ord('a')
        d[prev].pop(bisect_left(d[prev], a))
        next = ord(b) - ord('a')
        insort(d[next], a)
        S[a] = b
    else:
        a = int(a); b = int(b)
        ans = 0
        for alpha in range(26):
            if bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1:
                ans += 1
        print(ans)
