from bisect import bisect_left

n = int(input())
s = list(input())
q = int(input())
query = [input() for _ in range(q)]

p = [[] for _ in range(26)]

for i, x in enumerate(s):
    p[ord(x) - ord('a')].append(i)

for x in query:
    a, b, c = x.split()
    #print(c)
    if a == '1':
        b = int(b) - 1
        if s[b] == c:
            continue
        d = ord(s[b]) - ord('a')
        e = ord(c) - ord('a')
        temp = bisect_left(p[d], b)
        p[d].pop(temp)
        temp = bisect_left(p[e], b)
        p[e].insert(temp, b)
        s[b] = c
    else:
        b = int(b) - 1
        c = int(c) - 1
        #print(b, c)
        ans = 0
        for i in range(26):
            L = bisect_left(p[i], b)
            if L >= len(p[i]):
                continue
            if p[i][L] <= c:
                ans += 1
        print(ans) from bisect import bisect_left 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 input() for _ in range(q) for _ in range(q) _ range(q) range q for _ in range(q) input() input query = [input() for _ in range(q)] query [input() for _ in range(q)] [] for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [] p = [[] for _ in range(26)] p [[] for _ in range(26)] for i, x in enumerate(s):
    p[ord(x) - ord('a')].append(i) i x enumerate(s) enumerate s p[ord(x) - ord('a')].append(i) [ord(x) - ord('a')].append [ord(x) - ord('a')] p ord(x) - ord('a') ord(x) ord x ord('a') ord 'a' append i for x in query:
    a, b, c = x.split()
    #print(c)
    if a == '1':
        b = int(b) - 1
        if s[b] == c:
            continue
        d = ord(s[b]) - ord('a')
        e = ord(c) - ord('a')
        temp = bisect_left(p[d], b)
        p[d].pop(temp)
        temp = bisect_left(p[e], b)
        p[e].insert(temp, b)
        s[b] = c
    else:
        b = int(b) - 1
        c = int(c) - 1
        #print(b, c)
        ans = 0
        for i in range(26):
            L = bisect_left(p[i], b)
            if L >= len(p[i]):
                continue
            if p[i][L] <= c:
                ans += 1
        print(ans) x query a, b, c = x.split() a x.split() x.split x split b c if a == '1':
        b = int(b) - 1
        if s[b] == c:
            continue
        d = ord(s[b]) - ord('a')
        e = ord(c) - ord('a')
        temp = bisect_left(p[d], b)
        p[d].pop(temp)
        temp = bisect_left(p[e], b)
        p[e].insert(temp, b)
        s[b] = c
    else:
        b = int(b) - 1
        c = int(c) - 1
        #print(b, c)
        ans = 0
        for i in range(26):
            L = bisect_left(p[i], b)
            if L >= len(p[i]):
                continue
            if p[i][L] <= c:
                ans += 1
        print(ans) a == '1' a '1' b = int(b) - 1 b int(b) - 1 int(b) int b 1 if s[b] == c:
            continue
         s[b] == c s[b] s b c continue d = ord(s[b]) - ord('a') d ord(s[b]) - ord('a') ord(s[b]) ord s[b] s b ord('a') ord 'a' e = ord(c) - ord('a') e ord(c) - ord('a') ord(c) ord c ord('a') ord 'a' temp = bisect_left(p[d], b) temp bisect_left(p[d], b) bisect_left p[d] p d b p[d].pop(temp) [d].pop [d] p d pop temp temp = bisect_left(p[e], b) temp bisect_left(p[e], b) bisect_left p[e] p e b p[e].insert(temp, b) [e].insert [e] p e insert temp b s[b] = c s[b] s b c b = int(b) - 1 b int(b) - 1 int(b) int b 1 c = int(c) - 1 c int(c) - 1 int(c) int c 1 ans = 0 ans 0 for i in range(26):
            L = bisect_left(p[i], b)
            if L >= len(p[i]):
                continue
            if p[i][L] <= c:
                ans += 1
         i range(26) range 26 L = bisect_left(p[i], b) L bisect_left(p[i], b) bisect_left p[i] p i b if L >= len(p[i]):
                continue
             L >= len(p[i]) L len(p[i]) len p[i] p i continue if p[i][L] <= c:
                ans += 1
         p[i][L] <= c p[i][L] [i] p i L c ans += 1 ans 1 print(ans) print ans p = [[] for _ in range(26)] [[] for _ in range(26)] p b, c = x.split() x.split() b b = int(b) - 1 int(b) - 1 b c = int(c) - 1 int(c) - 1 c ans = 0 0 ans query = [input() for _ in range(q)] [input() for _ in range(q)] query b = int(b) - 1 int(b) - 1 b temp = bisect_left(p[e], b) bisect_left(p[e], b) temp s = list(input()) list(input()) s temp = bisect_left(p[d], b) bisect_left(p[d], b) temp c = x.split() x.split() c n = int(input()) int(input()) n q = int(input()) int(input()) q a, b, c = x.split() x.split() a ans += 1 1 ans L = bisect_left(p[i], b) bisect_left(p[i], b) L d = ord(s[b]) - ord('a') ord(s[b]) - ord('a') d e = ord(c) - ord('a') ord(c) - ord('a') e
from bisect import bisect_left

n = int(input())
s = list(input())
q = int(input())
query = [input() for _ in range(q)]

p = [[] for _ in range(26)]

for i, x in enumerate(s):
    p[ord(x) - ord('a')].append(i)

for x in query:
    a, b, c = x.split()
    #print(c)
    if a == '1':
        b = int(b) - 1
        if s[b] == c:
            continue
        d = ord(s[b]) - ord('a')
        e = ord(c) - ord('a')
        temp = bisect_left(p[d], b)
        p[d].pop(temp)
        temp = bisect_left(p[e], b)
        p[e].insert(temp, b)
        s[b] = c
    else:
        b = int(b) - 1
        c = int(c) - 1
        #print(b, c)
        ans = 0
        for i in range(26):
            L = bisect_left(p[i], b)
            if L >= len(p[i]):
                continue
            if p[i][L] <= c:
                ans += 1
        print(ans)
