import bisect
n = int(input())
s = list(input())
alp = 'abcdefghijklmnopqrstuvwxyz'
cnt = {c: [] for c in alp}

for i, c in enumerate(s):
    cnt[c].append(i)

q = int(input())
for _ in range(q):
    t, x, y = input().split()
    ans = 0
    if t == '1':
        i, c = int(x) - 1, y
        if s[i] == c:
            continue
        a = bisect.bisect_left(cnt[s[i]], i)
        cnt[s[i]].pop(a)
        s[i] = c
        b = bisect.bisect_left(cnt[c], i)
        cnt[c].insert(b, i)
    else:
        l, r = int(x) - 1, int(y) - 1
        for c in alp:
            a = bisect.bisect_left(cnt[c], l)
            if a < len(cnt[c]) and cnt[c][a] <= r:
                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 alp = 'abcdefghijklmnopqrstuvwxyz' alp 'abcdefghijklmnopqrstuvwxyz' c: [] for c in alp for c in alp c alp for c in alp c [] cnt = {c: [] for c in alp} cnt {c: [] for c in alp} for i, c in enumerate(s):
    cnt[c].append(i) i c enumerate(s) enumerate s cnt[c].append(i) [c].append [c] cnt c append i q = int(input()) q int(input()) int input() input for _ in range(q):
    t, x, y = input().split()
    ans = 0
    if t == '1':
        i, c = int(x) - 1, y
        if s[i] == c:
            continue
        a = bisect.bisect_left(cnt[s[i]], i)
        cnt[s[i]].pop(a)
        s[i] = c
        b = bisect.bisect_left(cnt[c], i)
        cnt[c].insert(b, i)
    else:
        l, r = int(x) - 1, int(y) - 1
        for c in alp:
            a = bisect.bisect_left(cnt[c], l)
            if a < len(cnt[c]) and cnt[c][a] <= r:
                ans += 1

        print(ans) _ range(q) range q t, x, y = input().split() t input().split() ().split () input split x y ans = 0 ans 0 if t == '1':
        i, c = int(x) - 1, y
        if s[i] == c:
            continue
        a = bisect.bisect_left(cnt[s[i]], i)
        cnt[s[i]].pop(a)
        s[i] = c
        b = bisect.bisect_left(cnt[c], i)
        cnt[c].insert(b, i)
    else:
        l, r = int(x) - 1, int(y) - 1
        for c in alp:
            a = bisect.bisect_left(cnt[c], l)
            if a < len(cnt[c]) and cnt[c][a] <= r:
                ans += 1

        print(ans) t == '1' t '1' i, c = int(x) - 1, y i int(x) - 1 int(x) int x 1 c y if s[i] == c:
            continue
         s[i] == c s[i] s i c continue a = bisect.bisect_left(cnt[s[i]], i) a bisect.bisect_left(cnt[s[i]], i) bisect.bisect_left bisect bisect_left cnt[s[i]] cnt s[i] s i i cnt[s[i]].pop(a) [s[i]].pop [s[i]] cnt s[i] s i pop a s[i] = c s[i] s i c b = bisect.bisect_left(cnt[c], i) b bisect.bisect_left(cnt[c], i) bisect.bisect_left bisect bisect_left cnt[c] cnt c i cnt[c].insert(b, i) [c].insert [c] cnt c insert b i l, r = int(x) - 1, int(y) - 1 l int(x) - 1 int(x) int x 1 r int(y) - 1 int(y) int y 1 for c in alp:
            a = bisect.bisect_left(cnt[c], l)
            if a < len(cnt[c]) and cnt[c][a] <= r:
                ans += 1

         c alp a = bisect.bisect_left(cnt[c], l) a bisect.bisect_left(cnt[c], l) bisect.bisect_left bisect bisect_left cnt[c] cnt c l if a < len(cnt[c]) and cnt[c][a] <= r:
                ans += 1

         a < len(cnt[c]) and cnt[c][a] <= r a < len(cnt[c]) a len(cnt[c]) len cnt[c] cnt c cnt[c][a] <= r cnt[c][a] [c] cnt c a r ans += 1 ans 1 print(ans) print ans t, x, y = input().split() input().split() t a = bisect.bisect_left(cnt[s[i]], i) bisect.bisect_left(cnt[s[i]], i) a n = int(input()) int(input()) n q = int(input()) int(input()) q i, c = int(x) - 1, y int(x) - 1 i ans += 1 1 ans cnt = {c: [] for c in alp} {c: [] for c in alp} cnt r = int(x) - 1, int(y) - 1 int(y) - 1 r alp = 'abcdefghijklmnopqrstuvwxyz' 'abcdefghijklmnopqrstuvwxyz' alp c = int(x) - 1, y y c b = bisect.bisect_left(cnt[c], i) bisect.bisect_left(cnt[c], i) b s = list(input()) list(input()) s l, r = int(x) - 1, int(y) - 1 int(x) - 1 l ans = 0 0 ans y = input().split() input().split() y a = bisect.bisect_left(cnt[c], l) bisect.bisect_left(cnt[c], l) a x, y = input().split() input().split() x
import bisect
n = int(input())
s = list(input())
alp = 'abcdefghijklmnopqrstuvwxyz'
cnt = {c: [] for c in alp}

for i, c in enumerate(s):
    cnt[c].append(i)

q = int(input())
for _ in range(q):
    t, x, y = input().split()
    ans = 0
    if t == '1':
        i, c = int(x) - 1, y
        if s[i] == c:
            continue
        a = bisect.bisect_left(cnt[s[i]], i)
        cnt[s[i]].pop(a)
        s[i] = c
        b = bisect.bisect_left(cnt[c], i)
        cnt[c].insert(b, i)
    else:
        l, r = int(x) - 1, int(y) - 1
        for c in alp:
            a = bisect.bisect_left(cnt[c], l)
            if a < len(cnt[c]) and cnt[c][a] <= r:
                ans += 1

        print(ans)