#!/usr/bin/python3
import bisect

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

idxs = [ [] for i in range(26) ]
sl = [ s[i] for i in range(n) ]

for i in range(n):
    idxs[ord(s[i]) - ord('a')].append(i + 1)

#print(idxs)

qs = []
for i in range(q):
    qs.append(input())

for qi in qs:
    (op, x, y) = qi.split()
    if op == '1':
        j = int(x)
        c = y
        oc = sl[j - 1]
        if oc != c:
            sl[j - 1] = c
            idx = bisect.bisect_left(idxs[ord(oc) - ord('a')], j)
            del idxs[ord(oc) - ord('a')][idx]
            idx = bisect.bisect_left(idxs[ord(c) - ord('a')], j)
            idxs[ord(c) - ord('a')].insert(idx, j)
        
    elif op == '2':
        l = int(x)
        r = int(y)
        c = 0
        for i in range(26):
            il = bisect.bisect_left(idxs[i], l)
            ir = bisect.bisect_right(idxs[i], r)
            if il < ir:
                c += 1
        print(c) import bisect bisect n = int(input()) n int(input()) int input() input s = input() s input() input q = int(input()) q int(input()) int input() input [] for i in range(26) for i in range(26) i range(26) range 26 for i in range(26) [] idxs = [ [] for i in range(26) ] idxs [ [] for i in range(26) ] s[i] for i in range(n) for i in range(n) i range(n) range n for i in range(n) s[i] s i sl = [ s[i] for i in range(n) ] sl [ s[i] for i in range(n) ] for i in range(n):
    idxs[ord(s[i]) - ord('a')].append(i + 1)

#print(idxs) i range(n) range n idxs[ord(s[i]) - ord('a')].append(i + 1) [ord(s[i]) - ord('a')].append [ord(s[i]) - ord('a')] idxs ord(s[i]) - ord('a') ord(s[i]) ord s[i] s i ord('a') ord 'a' append i + 1 i 1 qs = [] qs [] for i in range(q):
    qs.append(input()) i range(q) range q qs.append(input()) qs.append qs append input() input for qi in qs:
    (op, x, y) = qi.split()
    if op == '1':
        j = int(x)
        c = y
        oc = sl[j - 1]
        if oc != c:
            sl[j - 1] = c
            idx = bisect.bisect_left(idxs[ord(oc) - ord('a')], j)
            del idxs[ord(oc) - ord('a')][idx]
            idx = bisect.bisect_left(idxs[ord(c) - ord('a')], j)
            idxs[ord(c) - ord('a')].insert(idx, j)
        
    elif op == '2':
        l = int(x)
        r = int(y)
        c = 0
        for i in range(26):
            il = bisect.bisect_left(idxs[i], l)
            ir = bisect.bisect_right(idxs[i], r)
            if il < ir:
                c += 1
        print(c) qi qs (op, x, y) = qi.split() (op, x, y) op x y qi.split() qi.split qi split if op == '1':
        j = int(x)
        c = y
        oc = sl[j - 1]
        if oc != c:
            sl[j - 1] = c
            idx = bisect.bisect_left(idxs[ord(oc) - ord('a')], j)
            del idxs[ord(oc) - ord('a')][idx]
            idx = bisect.bisect_left(idxs[ord(c) - ord('a')], j)
            idxs[ord(c) - ord('a')].insert(idx, j)
        
    elif op == '2':
        l = int(x)
        r = int(y)
        c = 0
        for i in range(26):
            il = bisect.bisect_left(idxs[i], l)
            ir = bisect.bisect_right(idxs[i], r)
            if il < ir:
                c += 1
        print(c) op == '1' op '1' j = int(x) j int(x) int x c = y c y oc = sl[j - 1] oc sl[j - 1] sl j - 1 j 1 if oc != c:
            sl[j - 1] = c
            idx = bisect.bisect_left(idxs[ord(oc) - ord('a')], j)
            del idxs[ord(oc) - ord('a')][idx]
            idx = bisect.bisect_left(idxs[ord(c) - ord('a')], j)
            idxs[ord(c) - ord('a')].insert(idx, j)
        
     oc != c oc c sl[j - 1] = c sl[j - 1] sl j - 1 j 1 c idx = bisect.bisect_left(idxs[ord(oc) - ord('a')], j) idx bisect.bisect_left(idxs[ord(oc) - ord('a')], j) bisect.bisect_left bisect bisect_left idxs[ord(oc) - ord('a')] idxs ord(oc) - ord('a') ord(oc) ord oc ord('a') ord 'a' j del idxs[ord(oc) - ord('a')][idx] idxs[ord(oc) - ord('a')][idx] [ord(oc) - ord('a')] idxs ord(oc) - ord('a') ord(oc) ord oc ord('a') ord 'a' idx idx = bisect.bisect_left(idxs[ord(c) - ord('a')], j) idx bisect.bisect_left(idxs[ord(c) - ord('a')], j) bisect.bisect_left bisect bisect_left idxs[ord(c) - ord('a')] idxs ord(c) - ord('a') ord(c) ord c ord('a') ord 'a' j idxs[ord(c) - ord('a')].insert(idx, j) [ord(c) - ord('a')].insert [ord(c) - ord('a')] idxs ord(c) - ord('a') ord(c) ord c ord('a') ord 'a' insert idx j elif op == '2':
        l = int(x)
        r = int(y)
        c = 0
        for i in range(26):
            il = bisect.bisect_left(idxs[i], l)
            ir = bisect.bisect_right(idxs[i], r)
            if il < ir:
                c += 1
        print(c) op == '2' op '2' l = int(x) l int(x) int x r = int(y) r int(y) int y c = 0 c 0 for i in range(26):
            il = bisect.bisect_left(idxs[i], l)
            ir = bisect.bisect_right(idxs[i], r)
            if il < ir:
                c += 1
         i range(26) range 26 il = bisect.bisect_left(idxs[i], l) il bisect.bisect_left(idxs[i], l) bisect.bisect_left bisect bisect_left idxs[i] idxs i l ir = bisect.bisect_right(idxs[i], r) ir bisect.bisect_right(idxs[i], r) bisect.bisect_right bisect bisect_right idxs[i] idxs i r if il < ir:
                c += 1
         il < ir il ir c += 1 c 1 print(c) print c c += 1 1 c r = int(y) int(y) r s = input() input() s ir = bisect.bisect_right(idxs[i], r) bisect.bisect_right(idxs[i], r) ir idx = bisect.bisect_left(idxs[ord(c) - ord('a')], j) bisect.bisect_left(idxs[ord(c) - ord('a')], j) idx il = bisect.bisect_left(idxs[i], l) bisect.bisect_left(idxs[i], l) il q = int(input()) int(input()) q oc = sl[j - 1] sl[j - 1] oc idxs = [ [] for i in range(26) ] [ [] for i in range(26) ] idxs c = 0 0 c sl = [ s[i] for i in range(n) ] [ s[i] for i in range(n) ] sl n = int(input()) int(input()) n c = y y c j = int(x) int(x) j idx = bisect.bisect_left(idxs[ord(oc) - ord('a')], j) bisect.bisect_left(idxs[ord(oc) - ord('a')], j) idx l = int(x) int(x) l qs = [] [] qs
#!/usr/bin/python3
import bisect

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

idxs = [ [] for i in range(26) ]
sl = [ s[i] for i in range(n) ]

for i in range(n):
    idxs[ord(s[i]) - ord('a')].append(i + 1)

#print(idxs)

qs = []
for i in range(q):
    qs.append(input())

for qi in qs:
    (op, x, y) = qi.split()
    if op == '1':
        j = int(x)
        c = y
        oc = sl[j - 1]
        if oc != c:
            sl[j - 1] = c
            idx = bisect.bisect_left(idxs[ord(oc) - ord('a')], j)
            del idxs[ord(oc) - ord('a')][idx]
            idx = bisect.bisect_left(idxs[ord(c) - ord('a')], j)
            idxs[ord(c) - ord('a')].insert(idx, j)
        
    elif op == '2':
        l = int(x)
        r = int(y)
        c = 0
        for i in range(26):
            il = bisect.bisect_left(idxs[i], l)
            ir = bisect.bisect_right(idxs[i], r)
            if il < ir:
                c += 1
        print(c)
