import sys
# input = sys.stdin.buffer.readline
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

import bisect
from string import ascii_lowercase
d = dict()
for i, c in enumerate(ascii_lowercase):
    d[c] = i

N = int(input())
S = list(input())
lst = [[] for _ in range(26)]
for i in range(N):
    lst[d[S[i]]].append(i)

Q = int(input())
for q in range(Q):
    a, b, c = input().split()
    if a=='1':
        i = int(b)-1
        if c == S[i]:   # 変更なし
            continue
        idx = bisect.bisect_left(lst[d[S[i]]],i)
        del lst[d[S[i]]][idx]
        bisect.insort_left(lst[d[c]],i)
        S[i] = c
    else:
        l = int(b)-1
        r = int(c)
        ans = 0
        for i in range(26):
            cnt = bisect.bisect_left(lst[i],r) - bisect.bisect_left(lst[i],l)
            if cnt:
                ans += 1
        print(ans) import sys sys def input(): return sys.stdin.readline().rstrip() input sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 import bisect bisect from string import ascii_lowercase d = dict() d dict() dict for i, c in enumerate(ascii_lowercase):
    d[c] = i i c enumerate(ascii_lowercase) enumerate ascii_lowercase d[c] = i d[c] d c i N = int(input()) N int(input()) int input() input S = list(input()) S list(input()) list input() input [] for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [] lst = [[] for _ in range(26)] lst [[] for _ in range(26)] for i in range(N):
    lst[d[S[i]]].append(i) i range(N) range N lst[d[S[i]]].append(i) [d[S[i]]].append [d[S[i]]] lst d[S[i]] d S[i] S i append i Q = int(input()) Q int(input()) int input() input for q in range(Q):
    a, b, c = input().split()
    if a=='1':
        i = int(b)-1
        if c == S[i]:   # 変更なし
            continue
        idx = bisect.bisect_left(lst[d[S[i]]],i)
        del lst[d[S[i]]][idx]
        bisect.insort_left(lst[d[c]],i)
        S[i] = c
    else:
        l = int(b)-1
        r = int(c)
        ans = 0
        for i in range(26):
            cnt = bisect.bisect_left(lst[i],r) - bisect.bisect_left(lst[i],l)
            if cnt:
                ans += 1
        print(ans) q range(Q) range Q a, b, c = input().split() a input().split() ().split () input split b c if a=='1':
        i = int(b)-1
        if c == S[i]:   # 変更なし
            continue
        idx = bisect.bisect_left(lst[d[S[i]]],i)
        del lst[d[S[i]]][idx]
        bisect.insort_left(lst[d[c]],i)
        S[i] = c
    else:
        l = int(b)-1
        r = int(c)
        ans = 0
        for i in range(26):
            cnt = bisect.bisect_left(lst[i],r) - bisect.bisect_left(lst[i],l)
            if cnt:
                ans += 1
        print(ans) a=='1' a '1' i = int(b)-1 i int(b)-1 int(b) int b 1 if c == S[i]:   # 変更なし
            continue
         c == S[i] c S[i] S i continue idx = bisect.bisect_left(lst[d[S[i]]],i) idx bisect.bisect_left(lst[d[S[i]]],i) bisect.bisect_left bisect bisect_left lst[d[S[i]]] lst d[S[i]] d S[i] S i i del lst[d[S[i]]][idx] lst[d[S[i]]][idx] [d[S[i]]] lst d[S[i]] d S[i] S i idx bisect.insort_left(lst[d[c]],i) bisect.insort_left bisect insort_left lst[d[c]] lst d[c] d c i S[i] = c S[i] S i c l = int(b)-1 l int(b)-1 int(b) int b 1 r = int(c) r int(c) int c ans = 0 ans 0 for i in range(26):
            cnt = bisect.bisect_left(lst[i],r) - bisect.bisect_left(lst[i],l)
            if cnt:
                ans += 1
         i range(26) range 26 cnt = bisect.bisect_left(lst[i],r) - bisect.bisect_left(lst[i],l) cnt bisect.bisect_left(lst[i],r) - bisect.bisect_left(lst[i],l) bisect.bisect_left(lst[i],r) bisect.bisect_left bisect bisect_left lst[i] lst i r bisect.bisect_left(lst[i],l) bisect.bisect_left bisect bisect_left lst[i] lst i l if cnt:
                ans += 1
         cnt ans += 1 ans 1 print(ans) print ans idx = bisect.bisect_left(lst[d[S[i]]],i) bisect.bisect_left(lst[d[S[i]]],i) idx def input(): return sys.stdin.readline().rstrip() def input(): return sys.stdin.readline().rstrip() input Q = int(input()) int(input()) Q cnt = bisect.bisect_left(lst[i],r) - bisect.bisect_left(lst[i],l) bisect.bisect_left(lst[i],r) - bisect.bisect_left(lst[i],l) cnt b, c = input().split() input().split() b c = input().split() input().split() c S = list(input()) list(input()) S N = int(input()) int(input()) N lst = [[] for _ in range(26)] [[] for _ in range(26)] lst d = dict() dict() d a, b, c = input().split() input().split() a ans += 1 1 ans ans = 0 0 ans i = int(b)-1 int(b)-1 i l = int(b)-1 int(b)-1 l r = int(c) int(c) r
import sys
# input = sys.stdin.buffer.readline
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

import bisect
from string import ascii_lowercase
d = dict()
for i, c in enumerate(ascii_lowercase):
    d[c] = i

N = int(input())
S = list(input())
lst = [[] for _ in range(26)]
for i in range(N):
    lst[d[S[i]]].append(i)

Q = int(input())
for q in range(Q):
    a, b, c = input().split()
    if a=='1':
        i = int(b)-1
        if c == S[i]:   # 変更なし
            continue
        idx = bisect.bisect_left(lst[d[S[i]]],i)
        del lst[d[S[i]]][idx]
        bisect.insort_left(lst[d[c]],i)
        S[i] = c
    else:
        l = int(b)-1
        r = int(c)
        ans = 0
        for i in range(26):
            cnt = bisect.bisect_left(lst[i],r) - bisect.bisect_left(lst[i],l)
            if cnt:
                ans += 1
        print(ans)
