import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

seg_unit = 0


def seg_f(x, y):
    return x | y


def build(seg, raw_data):
    N = len(seg) // 2
    seg[N:] = raw_data
    for i in range(N - 1, 0, -1):
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1])


def set_val(seg, i, x):
    N = len(seg) // 2
    i += N
    seg[i] = x
    while i > 1:
        i >>= 1
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1])


def fold(seg, l, r):
    vl = vr = 0
    N = len(seg) // 2
    l, r = l + N, r + N
    while l < r:
        if l & 1:
            vl = seg_f(vl, seg[l])
            l += 1
        if r & 1:
            r -= 1
            vr = seg_f(seg[r], vr)
        l, r = l >> 1, r >> 1
    return seg_f(vl, vr)

def main(N, S, query):
    seg = np.zeros(N + N, np.int64)
    build(seg, 1 << S)
    for q in query:
        t, a, b = q.split()
        if t == b'1':
            a, b = int(a) - 1, ord(b) - ord('a')
            set_val(seg, a, 1 << b)
        else:
            a, b = int(a) - 1, int(b)
            x = fold(seg, a, b)
            print(bin(x).count('1'))

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    seg_f = cc_export(seg_f, (i8, i8))
    build = cc_export(build, (i8[:], i8[:]))
    set_val = cc_export(set_val, (i8[:], i8, i8))
    fold = cc_export(fold, (i8[:], i8, i8))
    cc.compile()

from my_module import seg_f, build, set_val, fold

N = int(readline())
S = np.array(list(readline().rstrip()), np.int64) - ord('a')
query = readlines()[1:]

main(N, S, query) import sys sys import numpy as np numpy read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines seg_unit = 0 seg_unit 0 def seg_f(x, y):
    return x | y seg_f return x | y x | y x y x x y y def build(seg, raw_data):
    N = len(seg) // 2
    seg[N:] = raw_data
    for i in range(N - 1, 0, -1):
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1]) build N = len(seg) // 2 N len(seg) // 2 len(seg) len seg 2 seg[N:] = raw_data seg[N:] seg N: N raw_data for i in range(N - 1, 0, -1):
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1]) i range(N - 1, 0, -1) range N - 1 N 1 0 -1 seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1]) seg[i] seg i seg_f(seg[i << 1], seg[i << 1 | 1]) seg_f seg[i << 1] seg i << 1 i 1 seg[i << 1 | 1] seg i << 1 | 1 i << 1 i 1 1 seg seg raw_data raw_data def set_val(seg, i, x):
    N = len(seg) // 2
    i += N
    seg[i] = x
    while i > 1:
        i >>= 1
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1]) set_val N = len(seg) // 2 N len(seg) // 2 len(seg) len seg 2 i += N i N seg[i] = x seg[i] seg i x while i > 1:
        i >>= 1
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1]) i > 1 i 1 i >>= 1 i 1 seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1]) seg[i] seg i seg_f(seg[i << 1], seg[i << 1 | 1]) seg_f seg[i << 1] seg i << 1 i 1 seg[i << 1 | 1] seg i << 1 | 1 i << 1 i 1 1 seg seg i i x x def fold(seg, l, r):
    vl = vr = 0
    N = len(seg) // 2
    l, r = l + N, r + N
    while l < r:
        if l & 1:
            vl = seg_f(vl, seg[l])
            l += 1
        if r & 1:
            r -= 1
            vr = seg_f(seg[r], vr)
        l, r = l >> 1, r >> 1
    return seg_f(vl, vr) fold vl = vr = 0 vl 0 = vr = 0 vr 0 N = len(seg) // 2 N len(seg) // 2 len(seg) len seg 2 l, r = l + N, r + N l l + N l N r r + N r N while l < r:
        if l & 1:
            vl = seg_f(vl, seg[l])
            l += 1
        if r & 1:
            r -= 1
            vr = seg_f(seg[r], vr)
        l, r = l >> 1, r >> 1
     l < r l r if l & 1:
            vl = seg_f(vl, seg[l])
            l += 1
         l & 1 l 1 vl = seg_f(vl, seg[l]) vl seg_f(vl, seg[l]) seg_f vl seg[l] seg l l += 1 l 1 if r & 1:
            r -= 1
            vr = seg_f(seg[r], vr)
         r & 1 r 1 r -= 1 r 1 vr = seg_f(seg[r], vr) vr seg_f(seg[r], vr) seg_f seg[r] seg r vr l, r = l >> 1, r >> 1 l l >> 1 l 1 r r >> 1 r 1 return seg_f(vl, vr) seg_f(vl, vr) seg_f vl vr seg seg l l r r def main(N, S, query):
    seg = np.zeros(N + N, np.int64)
    build(seg, 1 << S)
    for q in query:
        t, a, b = q.split()
        if t == b'1':
            a, b = int(a) - 1, ord(b) - ord('a')
            set_val(seg, a, 1 << b)
        else:
            a, b = int(a) - 1, int(b)
            x = fold(seg, a, b)
            print(bin(x).count('1')) main seg = np.zeros(N + N, np.int64) seg np.zeros(N + N, np.int64) np.zeros np zeros N + N N N np.int64 np int64 build(seg, 1 << S) build seg 1 << S 1 S for q in query:
        t, a, b = q.split()
        if t == b'1':
            a, b = int(a) - 1, ord(b) - ord('a')
            set_val(seg, a, 1 << b)
        else:
            a, b = int(a) - 1, int(b)
            x = fold(seg, a, b)
            print(bin(x).count('1')) q query t, a, b = q.split() t q.split() q.split q split a b if t == b'1':
            a, b = int(a) - 1, ord(b) - ord('a')
            set_val(seg, a, 1 << b)
        else:
            a, b = int(a) - 1, int(b)
            x = fold(seg, a, b)
            print(bin(x).count('1')) t == b'1' t b'1' a, b = int(a) - 1, ord(b) - ord('a') a int(a) - 1 int(a) int a 1 b ord(b) - ord('a') ord(b) ord b ord('a') ord 'a' set_val(seg, a, 1 << b) set_val seg a 1 << b 1 b a, b = int(a) - 1, int(b) a int(a) - 1 int(a) int a 1 b int(b) int b x = fold(seg, a, b) x fold(seg, a, b) fold seg a b print(bin(x).count('1')) print bin(x).count('1') (x).count (x) bin x count '1' N N S S query query if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    seg_f = cc_export(seg_f, (i8, i8))
    build = cc_export(build, (i8[:], i8[:]))
    set_val = cc_export(set_val, (i8[:], i8, i8))
    fold = cc_export(fold, (i8[:], i8, i8))
    cc.compile() sys.argv[-1] == 'ONLINE_JUDGE' sys.argv[-1] sys.argv sys argv -1 'ONLINE_JUDGE' import numba numba from numba.pycc import CC i8 = numba.int64 i8 numba.int64 numba int64 cc = CC('my_module') cc CC('my_module') CC 'my_module' def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

     cc_export cc.export(f.__name__, signature)(f) cc.export(f.__name__, signature) cc.export cc export f.__name__ f __name__ signature f return numba.njit(f) numba.njit(f) numba.njit numba njit f f f signature signature seg_f = cc_export(seg_f, (i8, i8)) seg_f cc_export(seg_f, (i8, i8)) cc_export seg_f (i8, i8) i8 i8 build = cc_export(build, (i8[:], i8[:])) build cc_export(build, (i8[:], i8[:])) cc_export build (i8[:], i8[:]) i8[:] i8 : i8[:] i8 : set_val = cc_export(set_val, (i8[:], i8, i8)) set_val cc_export(set_val, (i8[:], i8, i8)) cc_export set_val (i8[:], i8, i8) i8[:] i8 : i8 i8 fold = cc_export(fold, (i8[:], i8, i8)) fold cc_export(fold, (i8[:], i8, i8)) cc_export fold (i8[:], i8, i8) i8[:] i8 : i8 i8 cc.compile() cc.compile cc compile from my_module import seg_f, build, set_val, fold N = int(readline()) N int(readline()) int readline() readline S = np.array(list(readline().rstrip()), np.int64) - ord('a') S np.array(list(readline().rstrip()), np.int64) - ord('a') np.array(list(readline().rstrip()), np.int64) np.array np array list(readline().rstrip()) list readline().rstrip() ().rstrip () readline rstrip np.int64 np int64 ord('a') ord 'a' query = readlines()[1:] query readlines()[1:] () readlines 1: 1 main(N, S, query) main N S query readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

     def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

     cc_export read = sys.stdin.buffer.read sys.stdin.buffer.read read def build(seg, raw_data):
    N = len(seg) // 2
    seg[N:] = raw_data
    for i in range(N - 1, 0, -1):
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1]) def build(seg, raw_data):
    N = len(seg) // 2
    seg[N:] = raw_data
    for i in range(N - 1, 0, -1):
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1]) build def main(N, S, query):
    seg = np.zeros(N + N, np.int64)
    build(seg, 1 << S)
    for q in query:
        t, a, b = q.split()
        if t == b'1':
            a, b = int(a) - 1, ord(b) - ord('a')
            set_val(seg, a, 1 << b)
        else:
            a, b = int(a) - 1, int(b)
            x = fold(seg, a, b)
            print(bin(x).count('1')) def main(N, S, query):
    seg = np.zeros(N + N, np.int64)
    build(seg, 1 << S)
    for q in query:
        t, a, b = q.split()
        if t == b'1':
            a, b = int(a) - 1, ord(b) - ord('a')
            set_val(seg, a, 1 << b)
        else:
            a, b = int(a) - 1, int(b)
            x = fold(seg, a, b)
            print(bin(x).count('1')) main def fold(seg, l, r):
    vl = vr = 0
    N = len(seg) // 2
    l, r = l + N, r + N
    while l < r:
        if l & 1:
            vl = seg_f(vl, seg[l])
            l += 1
        if r & 1:
            r -= 1
            vr = seg_f(seg[r], vr)
        l, r = l >> 1, r >> 1
    return seg_f(vl, vr) def fold(seg, l, r):
    vl = vr = 0
    N = len(seg) // 2
    l, r = l + N, r + N
    while l < r:
        if l & 1:
            vl = seg_f(vl, seg[l])
            l += 1
        if r & 1:
            r -= 1
            vr = seg_f(seg[r], vr)
        l, r = l >> 1, r >> 1
    return seg_f(vl, vr) fold def seg_f(x, y):
    return x | y def seg_f(x, y):
    return x | y seg_f build = cc_export(build, (i8[:], i8[:])) cc_export(build, (i8[:], i8[:])) build readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline def set_val(seg, i, x):
    N = len(seg) // 2
    i += N
    seg[i] = x
    while i > 1:
        i >>= 1
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1]) def set_val(seg, i, x):
    N = len(seg) // 2
    i += N
    seg[i] = x
    while i > 1:
        i >>= 1
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1]) set_val set_val = cc_export(set_val, (i8[:], i8, i8)) cc_export(set_val, (i8[:], i8, i8)) set_val query = readlines()[1:] readlines()[1:] query seg_unit = 0 0 seg_unit seg_f = cc_export(seg_f, (i8, i8)) cc_export(seg_f, (i8, i8)) seg_f S = np.array(list(readline().rstrip()), np.int64) - ord('a') np.array(list(readline().rstrip()), np.int64) - ord('a') S i8 = numba.int64 numba.int64 i8 fold = cc_export(fold, (i8[:], i8, i8)) cc_export(fold, (i8[:], i8, i8)) fold N = int(readline()) int(readline()) N cc = CC('my_module') CC('my_module') cc
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

seg_unit = 0


def seg_f(x, y):
    return x | y


def build(seg, raw_data):
    N = len(seg) // 2
    seg[N:] = raw_data
    for i in range(N - 1, 0, -1):
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1])


def set_val(seg, i, x):
    N = len(seg) // 2
    i += N
    seg[i] = x
    while i > 1:
        i >>= 1
        seg[i] = seg_f(seg[i << 1], seg[i << 1 | 1])


def fold(seg, l, r):
    vl = vr = 0
    N = len(seg) // 2
    l, r = l + N, r + N
    while l < r:
        if l & 1:
            vl = seg_f(vl, seg[l])
            l += 1
        if r & 1:
            r -= 1
            vr = seg_f(seg[r], vr)
        l, r = l >> 1, r >> 1
    return seg_f(vl, vr)

def main(N, S, query):
    seg = np.zeros(N + N, np.int64)
    build(seg, 1 << S)
    for q in query:
        t, a, b = q.split()
        if t == b'1':
            a, b = int(a) - 1, ord(b) - ord('a')
            set_val(seg, a, 1 << b)
        else:
            a, b = int(a) - 1, int(b)
            x = fold(seg, a, b)
            print(bin(x).count('1'))

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    seg_f = cc_export(seg_f, (i8, i8))
    build = cc_export(build, (i8[:], i8[:]))
    set_val = cc_export(set_val, (i8[:], i8, i8))
    fold = cc_export(fold, (i8[:], i8, i8))
    cc.compile()

from my_module import seg_f, build, set_val, fold

N = int(readline())
S = np.array(list(readline().rstrip()), np.int64) - ord('a')
query = readlines()[1:]

main(N, S, query)