from bisect import bisect_left,bisect_right,insort

n = int(input())
s = list("-" + str(input()))
lis = [[] for i in range(26)]
for i in range(1,n+1):
    num = ord(s[i])-ord("a")
    lis[num].append(i)

q = int(input())
for turn in range(q):
    query = list(map(str,input().split()))
    if query[0] == "1":
        a = int(query[1])
        if s[a] == query[2]:
            continue
        num = ord(s[a])-ord("a")
        lis[num].pop(bisect_left(lis[num],a))
        next = ord(query[2])-ord("a")
        insort(lis[next],a)
        s[a] = query[2]
    else:
        a,b = int(query[1]),int(query[2])
        ans = 0
        for alphabet in range(26):
            if bisect_right(lis[alphabet],b)-bisect_left(lis[alphabet],a) >= 1:
                ans += 1
        print(ans) from bisect import bisect_left,bisect_right,insort n = int(input()) n int(input()) int input() input s = list("-" + str(input())) s list("-" + str(input())) list "-" + str(input()) "-" str(input()) str input() input [] for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) [] lis = [[] for i in range(26)] lis [[] for i in range(26)] for i in range(1,n+1):
    num = ord(s[i])-ord("a")
    lis[num].append(i) i range(1,n+1) range 1 n+1 n 1 num = ord(s[i])-ord("a") num ord(s[i])-ord("a") ord(s[i]) ord s[i] s i ord("a") ord "a" lis[num].append(i) [num].append [num] lis num append i q = int(input()) q int(input()) int input() input for turn in range(q):
    query = list(map(str,input().split()))
    if query[0] == "1":
        a = int(query[1])
        if s[a] == query[2]:
            continue
        num = ord(s[a])-ord("a")
        lis[num].pop(bisect_left(lis[num],a))
        next = ord(query[2])-ord("a")
        insort(lis[next],a)
        s[a] = query[2]
    else:
        a,b = int(query[1]),int(query[2])
        ans = 0
        for alphabet in range(26):
            if bisect_right(lis[alphabet],b)-bisect_left(lis[alphabet],a) >= 1:
                ans += 1
        print(ans) turn range(q) range q query = list(map(str,input().split())) query list(map(str,input().split())) list map(str,input().split()) map str input().split() ().split () input split if query[0] == "1":
        a = int(query[1])
        if s[a] == query[2]:
            continue
        num = ord(s[a])-ord("a")
        lis[num].pop(bisect_left(lis[num],a))
        next = ord(query[2])-ord("a")
        insort(lis[next],a)
        s[a] = query[2]
    else:
        a,b = int(query[1]),int(query[2])
        ans = 0
        for alphabet in range(26):
            if bisect_right(lis[alphabet],b)-bisect_left(lis[alphabet],a) >= 1:
                ans += 1
        print(ans) query[0] == "1" query[0] query 0 "1" a = int(query[1]) a int(query[1]) int query[1] query 1 if s[a] == query[2]:
            continue
         s[a] == query[2] s[a] s a query[2] query 2 continue num = ord(s[a])-ord("a") num ord(s[a])-ord("a") ord(s[a]) ord s[a] s a ord("a") ord "a" lis[num].pop(bisect_left(lis[num],a)) [num].pop [num] lis num pop bisect_left(lis[num],a) bisect_left lis[num] lis num a next = ord(query[2])-ord("a") next ord(query[2])-ord("a") ord(query[2]) ord query[2] query 2 ord("a") ord "a" insort(lis[next],a) insort lis[next] lis next a s[a] = query[2] s[a] s a query[2] query 2 a,b = int(query[1]),int(query[2]) a int(query[1]) int query[1] query 1 b int(query[2]) int query[2] query 2 ans = 0 ans 0 for alphabet in range(26):
            if bisect_right(lis[alphabet],b)-bisect_left(lis[alphabet],a) >= 1:
                ans += 1
         alphabet range(26) range 26 if bisect_right(lis[alphabet],b)-bisect_left(lis[alphabet],a) >= 1:
                ans += 1
         bisect_right(lis[alphabet],b)-bisect_left(lis[alphabet],a) >= 1 bisect_right(lis[alphabet],b)-bisect_left(lis[alphabet],a) bisect_right(lis[alphabet],b) bisect_right lis[alphabet] lis alphabet b bisect_left(lis[alphabet],a) bisect_left lis[alphabet] lis alphabet a 1 ans += 1 ans 1 print(ans) print ans n = int(input()) int(input()) n num = ord(s[i])-ord("a") ord(s[i])-ord("a") num a,b = int(query[1]),int(query[2]) int(query[1]) a s = list("-" + str(input())) list("-" + str(input())) s lis = [[] for i in range(26)] [[] for i in range(26)] lis a = int(query[1]) int(query[1]) a ans = 0 0 ans next = ord(query[2])-ord("a") ord(query[2])-ord("a") next ans += 1 1 ans b = int(query[1]),int(query[2]) int(query[2]) b num = ord(s[a])-ord("a") ord(s[a])-ord("a") num query = list(map(str,input().split())) list(map(str,input().split())) query q = int(input()) int(input()) q
from bisect import bisect_left,bisect_right,insort

n = int(input())
s = list("-" + str(input()))
lis = [[] for i in range(26)]
for i in range(1,n+1):
    num = ord(s[i])-ord("a")
    lis[num].append(i)

q = int(input())
for turn in range(q):
    query = list(map(str,input().split()))
    if query[0] == "1":
        a = int(query[1])
        if s[a] == query[2]:
            continue
        num = ord(s[a])-ord("a")
        lis[num].pop(bisect_left(lis[num],a))
        next = ord(query[2])-ord("a")
        insort(lis[next],a)
        s[a] = query[2]
    else:
        a,b = int(query[1]),int(query[2])
        ans = 0
        for alphabet in range(26):
            if bisect_right(lis[alphabet],b)-bisect_left(lis[alphabet],a) >= 1:
                ans += 1
        print(ans)