import sys
input = sys.stdin.readline

n = int(input())
s = str(input())
A = list(s)
A = A[0:n]

A = [{ord(c)-ord('a')} for c in A]
#print(A)

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

def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = 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] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+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%2 == 0:
            res = segfunc(res, seg[p])
        if q%2 == 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

# identity element
ide_ele = set()

# num: n以上の最小の2のべき乗
num = 2**(n-1).bit_length()
seg = [ide_ele]*2*num

init(A)

q = int(input())

for _ in range(q):
    c, x, y = map(str, input().split())
    if c == '1':
        x = int(x)-1
        y = {ord(y)-ord('a')}
        update(x, y)
    else:
        l = int(x)-1
        r = int(y)-1
        print(len(query(l, r+1))) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n = int(input()) n int(input()) int input() input s = str(input()) s str(input()) str input() input A = list(s) A list(s) list s A = A[0:n] A A[0:n] A 0:n 0 n {ord(c)-ord('a')} for c in A for c in A c A for c in A {ord(c)-ord('a')} A = [{ord(c)-ord('a')} for c in A] A [{ord(c)-ord('a')} for c in A] 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] = 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] = init_val[i]
    # built
     i range(n) range n seg[i+num-1] = init_val[i] seg[i+num-1] seg i+num-1 i+num i num 1 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] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) update k += num - 1 k num - 1 num 1 seg[k] = x seg[k] seg k x while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) k k = (k-1)//2 k (k-1)//2 k-1 k 1 2 seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) seg[k] seg k segfunc(seg[2*k+1], seg[2*k+2]) segfunc seg[2*k+1] seg 2*k+1 2*k 2 k 1 seg[2*k+2] seg 2*k+2 2*k 2 k 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%2 == 0:
            res = segfunc(res, seg[p])
        if q%2 == 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

# identity element 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%2 == 0:
            res = segfunc(res, seg[p])
        if q%2 == 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%2 == 0:
            res = segfunc(res, seg[p])
         p%2 == 0 p%2 p 2 0 res = segfunc(res, seg[p]) res segfunc(res, seg[p]) segfunc res seg[p] seg p if q%2 == 1:
            res = segfunc(res, seg[q])
            q -= 1
         q%2 == 1 q%2 q 2 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 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 = [ide_ele]*2*num seg [ide_ele]*2*num [ide_ele]*2 [ide_ele] ide_ele 2 num init(A) init A q = int(input()) q int(input()) int input() input for _ in range(q):
    c, x, y = map(str, input().split())
    if c == '1':
        x = int(x)-1
        y = {ord(y)-ord('a')}
        update(x, y)
    else:
        l = int(x)-1
        r = int(y)-1
        print(len(query(l, r+1))) _ range(q) range q c, x, y = map(str, input().split()) c map(str, input().split()) map str input().split() ().split () input split x y if c == '1':
        x = int(x)-1
        y = {ord(y)-ord('a')}
        update(x, y)
    else:
        l = int(x)-1
        r = int(y)-1
        print(len(query(l, r+1))) c == '1' c '1' x = int(x)-1 x int(x)-1 int(x) int x 1 y = {ord(y)-ord('a')} y {ord(y)-ord('a')} update(x, y) update x y l = int(x)-1 l int(x)-1 int(x) int x 1 r = int(y)-1 r int(y)-1 int(y) int y 1 print(len(query(l, r+1))) print len(query(l, r+1)) len query(l, r+1) query l r+1 r 1 n = int(input()) int(input()) n def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = 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] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2]) init A = [{ord(c)-ord('a')} for c in A] [{ord(c)-ord('a')} for c in A] A seg = [ide_ele]*2*num [ide_ele]*2*num seg A = list(s) list(s) A s = str(input()) str(input()) s 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%2 == 0:
            res = segfunc(res, seg[p])
        if q%2 == 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

# identity element 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%2 == 0:
            res = segfunc(res, seg[p])
        if q%2 == 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

# identity element query def segfunc(x, y):
    return x | y def segfunc(x, y):
    return x | y segfunc x, y = map(str, input().split()) map(str, input().split()) x y = map(str, input().split()) map(str, input().split()) y ide_ele = set() set() ide_ele q = int(input()) int(input()) q input = sys.stdin.readline sys.stdin.readline input x = int(x)-1 int(x)-1 x c, x, y = map(str, input().split()) map(str, input().split()) c l = int(x)-1 int(x)-1 l r = int(y)-1 int(y)-1 r A = A[0:n] A[0:n] A y = {ord(y)-ord('a')} {ord(y)-ord('a')} y num = 2**(n-1).bit_length() 2**(n-1).bit_length() num def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) update
import sys
input = sys.stdin.readline

n = int(input())
s = str(input())
A = list(s)
A = A[0:n]

A = [{ord(c)-ord('a')} for c in A]
#print(A)

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

def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = 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] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+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%2 == 0:
            res = segfunc(res, seg[p])
        if q%2 == 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

# identity element
ide_ele = set()

# num: n以上の最小の2のべき乗
num = 2**(n-1).bit_length()
seg = [ide_ele]*2*num

init(A)

q = int(input())

for _ in range(q):
    c, x, y = map(str, input().split())
    if c == '1':
        x = int(x)-1
        y = {ord(y)-ord('a')}
        update(x, y)
    else:
        l = int(x)-1
        r = int(y)-1
        print(len(query(l, r+1)))