N = int(input())
S = list(input())
Q = int(input())

'''
'init(a)': 配列aで初期化。O(N)
'update(k,x)': a[k]をxに変更 O(logN)
'query(p,q)': [p,q)について "segfunc" したものを返す O(logN)
'ide_ele' : 単位元。
'''

#####segfunc######


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[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 = 0

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


init_val = []
for s in S:
    init_val.append(1 << (ord(s)-ord('a')))
init(init_val)

for _ in range(Q):
    t, s, u = input().split()
    if t == '1':
        update(int(s)-1, 1 << (ord(u)-ord('a')))
    else:
        print(bin(query(int(s)-1, int(u))).count('1')) 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 '''
'init(a)': 配列aで初期化。O(N)
'update(k,x)': a[k]をxに変更 O(logN)
'query(p,q)': [p,q)について "segfunc" したものを返す O(logN)
'ide_ele' : 単位元。
''' 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[k*2+1], seg[k*2+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[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 = 0 ide_ele 0 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_val = [] init_val [] for s in S:
    init_val.append(1 << (ord(s)-ord('a'))) s S init_val.append(1 << (ord(s)-ord('a'))) init_val.append init_val append 1 << (ord(s)-ord('a')) 1 ord(s)-ord('a') ord(s) ord s ord('a') ord 'a' init(init_val) init init_val for _ in range(Q):
    t, s, u = input().split()
    if t == '1':
        update(int(s)-1, 1 << (ord(u)-ord('a')))
    else:
        print(bin(query(int(s)-1, int(u))).count('1')) _ range(Q) range Q t, s, u = input().split() t input().split() ().split () input split s u if t == '1':
        update(int(s)-1, 1 << (ord(u)-ord('a')))
    else:
        print(bin(query(int(s)-1, int(u))).count('1')) t == '1' t '1' update(int(s)-1, 1 << (ord(u)-ord('a'))) update int(s)-1 int(s) int s 1 1 << (ord(u)-ord('a')) 1 ord(u)-ord('a') ord(u) ord u ord('a') ord 'a' print(bin(query(int(s)-1, int(u))).count('1')) print bin(query(int(s)-1, int(u))).count('1') (query(int(s)-1, int(u))).count (query(int(s)-1, int(u))) bin query(int(s)-1, int(u)) query int(s)-1 int(s) int s 1 int(u) int u count '1' Q = int(input()) int(input()) Q 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 ide_ele = 0 0 ide_ele def update(k, x):
    k += num-1
    seg[k] = 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] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1], seg[k*2+2]) update num = 2**(N-1).bit_length() 2**(N-1).bit_length() num s, u = input().split() input().split() s init_val = [] [] init_val def segfunc(x, y):
    return x | y def segfunc(x, y):
    return x | y segfunc S = list(input()) list(input()) S u = input().split() input().split() u N = int(input()) int(input()) N seg = [ide_ele]*2*num [ide_ele]*2*num seg 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 t, s, u = input().split() input().split() t
N = int(input())
S = list(input())
Q = int(input())

'''
'init(a)': 配列aで初期化。O(N)
'update(k,x)': a[k]をxに変更 O(logN)
'query(p,q)': [p,q)について "segfunc" したものを返す O(logN)
'ide_ele' : 単位元。
'''

#####segfunc######


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[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 = 0

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


init_val = []
for s in S:
    init_val.append(1 << (ord(s)-ord('a')))
init(init_val)

for _ in range(Q):
    t, s, u = input().split()
    if t == '1':
        update(int(s)-1, 1 << (ord(u)-ord('a')))
    else:
        print(bin(query(int(s)-1, int(u))).count('1'))
