from bisect import bisect_right
from bisect import bisect_left

n = int(input())
s = list(input())
q = int(input())

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

for i, x in enumerate(s):
    ind_list[ord(x)-97].append(i)

for _ in range(q):
    _type, val1, val2 = input().split()
    if _type == '1':
        i = int(val1)-1
        c = val2
        if s[i] == c:
            continue
        ind_list[ord(s[i])-97].remove(i)
        p = bisect_right(ind_list[ord(c)-97], i)
        ind_list[ord(c)-97].insert(p, i)
        s[i] = c
    elif _type == '2':
        l = int(val1)-1
        r = int(val2)-1
        ans = 0
        for i in range(26):
            if bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) > 0:
                ans += 1
        print(ans)
    else:
        print('Exception caught!')
        exit() from bisect import bisect_right 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 [] for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [] ind_list = [[] for _ in range(26)] ind_list [[] for _ in range(26)] for i, x in enumerate(s):
    ind_list[ord(x)-97].append(i) i x enumerate(s) enumerate s ind_list[ord(x)-97].append(i) [ord(x)-97].append [ord(x)-97] ind_list ord(x)-97 ord(x) ord x 97 append i for _ in range(q):
    _type, val1, val2 = input().split()
    if _type == '1':
        i = int(val1)-1
        c = val2
        if s[i] == c:
            continue
        ind_list[ord(s[i])-97].remove(i)
        p = bisect_right(ind_list[ord(c)-97], i)
        ind_list[ord(c)-97].insert(p, i)
        s[i] = c
    elif _type == '2':
        l = int(val1)-1
        r = int(val2)-1
        ans = 0
        for i in range(26):
            if bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) > 0:
                ans += 1
        print(ans)
    else:
        print('Exception caught!')
        exit() _ range(q) range q _type, val1, val2 = input().split() _type input().split() ().split () input split val1 val2 if _type == '1':
        i = int(val1)-1
        c = val2
        if s[i] == c:
            continue
        ind_list[ord(s[i])-97].remove(i)
        p = bisect_right(ind_list[ord(c)-97], i)
        ind_list[ord(c)-97].insert(p, i)
        s[i] = c
    elif _type == '2':
        l = int(val1)-1
        r = int(val2)-1
        ans = 0
        for i in range(26):
            if bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) > 0:
                ans += 1
        print(ans)
    else:
        print('Exception caught!')
        exit() _type == '1' _type '1' i = int(val1)-1 i int(val1)-1 int(val1) int val1 1 c = val2 c val2 if s[i] == c:
            continue
         s[i] == c s[i] s i c continue ind_list[ord(s[i])-97].remove(i) [ord(s[i])-97].remove [ord(s[i])-97] ind_list ord(s[i])-97 ord(s[i]) ord s[i] s i 97 remove i p = bisect_right(ind_list[ord(c)-97], i) p bisect_right(ind_list[ord(c)-97], i) bisect_right ind_list[ord(c)-97] ind_list ord(c)-97 ord(c) ord c 97 i ind_list[ord(c)-97].insert(p, i) [ord(c)-97].insert [ord(c)-97] ind_list ord(c)-97 ord(c) ord c 97 insert p i s[i] = c s[i] s i c elif _type == '2':
        l = int(val1)-1
        r = int(val2)-1
        ans = 0
        for i in range(26):
            if bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) > 0:
                ans += 1
        print(ans)
     _type == '2' _type '2' l = int(val1)-1 l int(val1)-1 int(val1) int val1 1 r = int(val2)-1 r int(val2)-1 int(val2) int val2 1 ans = 0 ans 0 for i in range(26):
            if bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) > 0:
                ans += 1
         i range(26) range 26 if bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) > 0:
                ans += 1
         bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) > 0 bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) bisect_right(ind_list[i], r) bisect_right ind_list[i] ind_list i r bisect_left(ind_list[i], l) bisect_left ind_list[i] ind_list i l 0 ans += 1 ans 1 print(ans) print ans print('Exception caught!') print 'Exception caught!' exit() exit ans = 0 0 ans val1, val2 = input().split() input().split() val1 ind_list = [[] for _ in range(26)] [[] for _ in range(26)] ind_list r = int(val2)-1 int(val2)-1 r _type, val1, val2 = input().split() input().split() _type i = int(val1)-1 int(val1)-1 i p = bisect_right(ind_list[ord(c)-97], i) bisect_right(ind_list[ord(c)-97], i) p val2 = input().split() input().split() val2 l = int(val1)-1 int(val1)-1 l n = int(input()) int(input()) n s = list(input()) list(input()) s ans += 1 1 ans q = int(input()) int(input()) q c = val2 val2 c
from bisect import bisect_right
from bisect import bisect_left

n = int(input())
s = list(input())
q = int(input())

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

for i, x in enumerate(s):
    ind_list[ord(x)-97].append(i)

for _ in range(q):
    _type, val1, val2 = input().split()
    if _type == '1':
        i = int(val1)-1
        c = val2
        if s[i] == c:
            continue
        ind_list[ord(s[i])-97].remove(i)
        p = bisect_right(ind_list[ord(c)-97], i)
        ind_list[ord(c)-97].insert(p, i)
        s[i] = c
    elif _type == '2':
        l = int(val1)-1
        r = int(val2)-1
        ans = 0
        for i in range(26):
            if bisect_right(ind_list[i], r) - bisect_left(ind_list[i], l) > 0:
                ans += 1
        print(ans)
    else:
        print('Exception caught!')
        exit()
