#####segfunc######
def segfunc(x, y):
    return x | y


def init(init_val):
    # set_val
    for i in range(n):
        seg[i + num - 1] = set(init_val[i])
        # built
    for i in range(num - 2, -1, -1):
        seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])


def update(k, x):
    k += num - 1
    seg[k] = set(x)
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])


def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res


#####単位元######
ide_ele = set()

n = int(input())
S = input().strip()
Q = int(input())

num = 2 ** (n - 1).bit_length()
seg = [set()] * 2 * num

init(S)


for _ in range(Q):
    a, b, c = [x for x in input().split()]
    if a == "1":
        update(int(b) - 1, c)
    else:
        print(len(query(int(b) - 1, int(c)))) def segfunc(x, y):
    return x | y segfunc return x | y x | y x y x x y y def init(init_val):
    # set_val
    for i in range(n):
        seg[i + num - 1] = set(init_val[i])
        # built
    for i in range(num - 2, -1, -1):
        seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2]) init for i in range(n):
        seg[i + num - 1] = set(init_val[i])
        # built
     i range(n) range n seg[i + num - 1] = set(init_val[i]) seg[i + num - 1] seg i + num - 1 i + num i num 1 set(init_val[i]) set init_val[i] init_val i for i in range(num - 2, -1, -1):
        seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2]) i range(num - 2, -1, -1) range num - 2 num 2 -1 -1 seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2]) seg[i] seg i segfunc(seg[2 * i + 1], seg[2 * i + 2]) segfunc seg[2 * i + 1] seg 2 * i + 1 2 * i 2 i 1 seg[2 * i + 2] seg 2 * i + 2 2 * i 2 i 2 init_val init_val def update(k, x):
    k += num - 1
    seg[k] = set(x)
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2]) update k += num - 1 k num - 1 num 1 seg[k] = set(x) seg[k] seg k set(x) set x while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2]) k k = (k - 1) // 2 k (k - 1) // 2 k - 1 k 1 2 seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2]) seg[k] seg k segfunc(seg[k * 2 + 1], seg[k * 2 + 2]) segfunc seg[k * 2 + 1] seg k * 2 + 1 k * 2 k 2 1 seg[k * 2 + 2] seg k * 2 + 2 k * 2 k 2 2 k k x x def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res


#####単位元###### query if q <= p:
        return ide_ele
     q <= p q p return ide_ele ide_ele p += num - 1 p num - 1 num 1 q += num - 2 q num - 2 num 2 res = ide_ele res ide_ele while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
     q - p > 1 q - p q p 1 if p & 1 == 0:
            res = segfunc(res, seg[p])
         p & 1 == 0 p & 1 p 1 0 res = segfunc(res, seg[p]) res segfunc(res, seg[p]) segfunc res seg[p] seg p if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
         q & 1 == 1 q & 1 q 1 1 res = segfunc(res, seg[q]) res segfunc(res, seg[q]) segfunc res seg[q] seg q q -= 1 q 1 p = p // 2 p p // 2 p 2 q = (q - 1) // 2 q (q - 1) // 2 q - 1 q 1 2 if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
     p == q p q res = segfunc(res, seg[p]) res segfunc(res, seg[p]) segfunc res seg[p] seg p res = segfunc(segfunc(res, seg[p]), seg[q]) res segfunc(segfunc(res, seg[p]), seg[q]) segfunc segfunc(res, seg[p]) segfunc res seg[p] seg p seg[q] seg q return res res p p q q ide_ele = set() ide_ele set() set n = int(input()) n int(input()) int input() input S = input().strip() S input().strip() ().strip () input strip Q = int(input()) Q int(input()) int input() input num = 2 ** (n - 1).bit_length() num 2 ** (n - 1).bit_length() 2 (n - 1).bit_length() n - 1).bit_length n - 1 n 1 bit_length seg = [set()] * 2 * num seg [set()] * 2 * num [set()] * 2 [set()] set() set 2 num init(S) init S for _ in range(Q):
    a, b, c = [x for x in input().split()]
    if a == "1":
        update(int(b) - 1, c)
    else:
        print(len(query(int(b) - 1, int(c)))) _ range(Q) range Q x for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() x a, b, c = [x for x in input().split()] a [x for x in input().split()] b c if a == "1":
        update(int(b) - 1, c)
    else:
        print(len(query(int(b) - 1, int(c)))) a == "1" a "1" update(int(b) - 1, c) update int(b) - 1 int(b) int b 1 c print(len(query(int(b) - 1, int(c)))) print len(query(int(b) - 1, int(c))) len query(int(b) - 1, int(c)) query int(b) - 1 int(b) int b 1 int(c) int c def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res


#####単位元###### def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res


#####単位元###### query def update(k, x):
    k += num - 1
    seg[k] = set(x)
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2]) def update(k, x):
    k += num - 1
    seg[k] = set(x)
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2]) update ide_ele = set() set() ide_ele b, c = [x for x in input().split()] [x for x in input().split()] b seg = [set()] * 2 * num [set()] * 2 * num seg S = input().strip() input().strip() S c = [x for x in input().split()] [x for x in input().split()] c num = 2 ** (n - 1).bit_length() 2 ** (n - 1).bit_length() num Q = int(input()) int(input()) Q def segfunc(x, y):
    return x | y def segfunc(x, y):
    return x | y segfunc n = int(input()) int(input()) n a, b, c = [x for x in input().split()] [x for x in input().split()] a def init(init_val):
    # set_val
    for i in range(n):
        seg[i + num - 1] = set(init_val[i])
        # built
    for i in range(num - 2, -1, -1):
        seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2]) def init(init_val):
    # set_val
    for i in range(n):
        seg[i + num - 1] = set(init_val[i])
        # built
    for i in range(num - 2, -1, -1):
        seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2]) init
#####segfunc######
def segfunc(x, y):
    return x | y


def init(init_val):
    # set_val
    for i in range(n):
        seg[i + num - 1] = set(init_val[i])
        # built
    for i in range(num - 2, -1, -1):
        seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])


def update(k, x):
    k += num - 1
    seg[k] = set(x)
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])


def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res


#####単位元######
ide_ele = set()

n = int(input())
S = input().strip()
Q = int(input())

num = 2 ** (n - 1).bit_length()
seg = [set()] * 2 * num

init(S)


for _ in range(Q):
    a, b, c = [x for x in input().split()]
    if a == "1":
        update(int(b) - 1, c)
    else:
        print(len(query(int(b) - 1, int(c))))
