n = int(input())
S = input()
s = []
for i in range(n):
    s.append(S[i])
q = int(input())
BIT = []
for i in range(26):
    B = [0]*(n+1) #1-indexed
    BIT.append(B)

def sum_of_1_to_i(i, LIST):
    z = 0
    while i > 0:
        z += LIST[i]
        i -= i & (-i)
    return z

def update(i, j, LIST):
    while i <= n:
        LIST[i] += j
        i += i & (-i)

for i in range(n):
    k = ord(s[i])-97
    update(i+1, 1, BIT[k])

ans = []

for i in range(q):
    a,b,c = input().split()
    a = int(a)
    b = int(b)
    if a == 1:
        temp = s[b-1]
        if temp == c:
            None
        else:
            update(b, -1, BIT[ord(temp)-97])
            update(b, 1, BIT[ord(c)-97])
            s[b-1] = c
    else:
        c = int(c)
        cur = 0
        for j in range(26):
            if sum_of_1_to_i(c, BIT[j])-sum_of_1_to_i(b-1, BIT[j]) != 0:
                cur += 1
        ans.append(cur)
for i in range(len(ans)):
    print(ans[i]) n = int(input()) n int(input()) int input() input S = input() S input() input s = [] s [] for i in range(n):
    s.append(S[i]) i range(n) range n s.append(S[i]) s.append s append S[i] S i q = int(input()) q int(input()) int input() input BIT = [] BIT [] for i in range(26):
    B = [0]*(n+1) #1-indexed
    BIT.append(B) i range(26) range 26 B = [0]*(n+1) B [0]*(n+1) [0] 0 n+1 n 1 BIT.append(B) BIT.append BIT append B def sum_of_1_to_i(i, LIST):
    z = 0
    while i > 0:
        z += LIST[i]
        i -= i & (-i)
    return z sum_of_1_to_i z = 0 z 0 while i > 0:
        z += LIST[i]
        i -= i & (-i)
     i > 0 i 0 z += LIST[i] z LIST[i] LIST i i -= i & (-i) i i & (-i) i -i i return z z i i LIST LIST def update(i, j, LIST):
    while i <= n:
        LIST[i] += j
        i += i & (-i) update while i <= n:
        LIST[i] += j
        i += i & (-i) i <= n i n LIST[i] += j LIST[i] LIST i j i += i & (-i) i i & (-i) i -i i i i j j LIST LIST for i in range(n):
    k = ord(s[i])-97
    update(i+1, 1, BIT[k]) i range(n) range n k = ord(s[i])-97 k ord(s[i])-97 ord(s[i]) ord s[i] s i 97 update(i+1, 1, BIT[k]) update i+1 i 1 1 BIT[k] BIT k ans = [] ans [] for i in range(q):
    a,b,c = input().split()
    a = int(a)
    b = int(b)
    if a == 1:
        temp = s[b-1]
        if temp == c:
            None
        else:
            update(b, -1, BIT[ord(temp)-97])
            update(b, 1, BIT[ord(c)-97])
            s[b-1] = c
    else:
        c = int(c)
        cur = 0
        for j in range(26):
            if sum_of_1_to_i(c, BIT[j])-sum_of_1_to_i(b-1, BIT[j]) != 0:
                cur += 1
        ans.append(cur) i range(q) range q a,b,c = input().split() a input().split() ().split () input split b c a = int(a) a int(a) int a b = int(b) b int(b) int b if a == 1:
        temp = s[b-1]
        if temp == c:
            None
        else:
            update(b, -1, BIT[ord(temp)-97])
            update(b, 1, BIT[ord(c)-97])
            s[b-1] = c
    else:
        c = int(c)
        cur = 0
        for j in range(26):
            if sum_of_1_to_i(c, BIT[j])-sum_of_1_to_i(b-1, BIT[j]) != 0:
                cur += 1
        ans.append(cur) a == 1 a 1 temp = s[b-1] temp s[b-1] s b-1 b 1 if temp == c:
            None
        else:
            update(b, -1, BIT[ord(temp)-97])
            update(b, 1, BIT[ord(c)-97])
            s[b-1] = c
     temp == c temp c None update(b, -1, BIT[ord(temp)-97]) update b -1 BIT[ord(temp)-97] BIT ord(temp)-97 ord(temp) ord temp 97 update(b, 1, BIT[ord(c)-97]) update b 1 BIT[ord(c)-97] BIT ord(c)-97 ord(c) ord c 97 s[b-1] = c s[b-1] s b-1 b 1 c c = int(c) c int(c) int c cur = 0 cur 0 for j in range(26):
            if sum_of_1_to_i(c, BIT[j])-sum_of_1_to_i(b-1, BIT[j]) != 0:
                cur += 1
         j range(26) range 26 if sum_of_1_to_i(c, BIT[j])-sum_of_1_to_i(b-1, BIT[j]) != 0:
                cur += 1
         sum_of_1_to_i(c, BIT[j])-sum_of_1_to_i(b-1, BIT[j]) != 0 sum_of_1_to_i(c, BIT[j])-sum_of_1_to_i(b-1, BIT[j]) sum_of_1_to_i(c, BIT[j]) sum_of_1_to_i c BIT[j] BIT j sum_of_1_to_i(b-1, BIT[j]) sum_of_1_to_i b-1 b 1 BIT[j] BIT j 0 cur += 1 cur 1 ans.append(cur) ans.append ans append cur for i in range(len(ans)):
    print(ans[i]) i range(len(ans)) range len(ans) len ans print(ans[i]) print ans[i] ans i cur += 1 1 cur def sum_of_1_to_i(i, LIST):
    z = 0
    while i > 0:
        z += LIST[i]
        i -= i & (-i)
    return z def sum_of_1_to_i(i, LIST):
    z = 0
    while i > 0:
        z += LIST[i]
        i -= i & (-i)
    return z sum_of_1_to_i c = input().split() input().split() c q = int(input()) int(input()) q S = input() input() S b,c = input().split() input().split() b k = ord(s[i])-97 ord(s[i])-97 k B = [0]*(n+1) [0]*(n+1) B def update(i, j, LIST):
    while i <= n:
        LIST[i] += j
        i += i & (-i) def update(i, j, LIST):
    while i <= n:
        LIST[i] += j
        i += i & (-i) update a,b,c = input().split() input().split() a s = [] [] s a = int(a) int(a) a b = int(b) int(b) b n = int(input()) int(input()) n cur = 0 0 cur BIT = [] [] BIT c = int(c) int(c) c temp = s[b-1] s[b-1] temp ans = [] [] ans
n = int(input())
S = input()
s = []
for i in range(n):
    s.append(S[i])
q = int(input())
BIT = []
for i in range(26):
    B = [0]*(n+1) #1-indexed
    BIT.append(B)

def sum_of_1_to_i(i, LIST):
    z = 0
    while i > 0:
        z += LIST[i]
        i -= i & (-i)
    return z

def update(i, j, LIST):
    while i <= n:
        LIST[i] += j
        i += i & (-i)

for i in range(n):
    k = ord(s[i])-97
    update(i+1, 1, BIT[k])

ans = []

for i in range(q):
    a,b,c = input().split()
    a = int(a)
    b = int(b)
    if a == 1:
        temp = s[b-1]
        if temp == c:
            None
        else:
            update(b, -1, BIT[ord(temp)-97])
            update(b, 1, BIT[ord(c)-97])
            s[b-1] = c
    else:
        c = int(c)
        cur = 0
        for j in range(26):
            if sum_of_1_to_i(c, BIT[j])-sum_of_1_to_i(b-1, BIT[j]) != 0:
                cur += 1
        ans.append(cur)
for i in range(len(ans)):
    print(ans[i])
