import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
S = list(input())
Q = int(input())
q_list = [list(input().split()) for _ in range(Q)]

bit_tree = [[0] * (N+1) for _ in range(26)]
def BIT_add(i, tree):
    while i <= N:
        tree[i] += 1
        i += i&(-i)

def BIT_sub(i, tree):
    while i <= N:
        tree[i] -= 1
        i += i&(-i)

def BIT_sum(i, tree):
    s = 0
    while i:
        s += tree[i]
        i -= i&(-i)
    return s

for i in range(N):
    x = ord(S[i]) - ord('a')
    BIT_add(i + 1, bit_tree[x])

for q in range(Q):
    line = q_list[q]
    if line[0] == '1':
        i, c = line[1:]
        i = int(i) - 1
        old_c = ord(S[i]) - ord('a')
        new_c = ord(c) - ord('a')
        BIT_sub(i + 1, bit_tree[old_c])
        BIT_add(i + 1, bit_tree[new_c])
        S[i] = c
    else:
        l, r = map(int, line[1:])
        now = 0
        for i in range(26):
            cnt = BIT_sum(r, bit_tree[i]) - BIT_sum(l - 1, bit_tree[i])
            if cnt > 0:
                now += 1
        print(now) import sys sys import itertools itertools import time time import math math from heapq import heappop, heappush from collections import defaultdict from collections import Counter from collections import deque from itertools import permutations sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 INF = 10 ** 18 INF 10 ** 18 10 18 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 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 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 list(input().split()) for _ in range(Q) for _ in range(Q) _ range(Q) range Q for _ in range(Q) list(input().split()) list input().split() ().split () input split q_list = [list(input().split()) for _ in range(Q)] q_list [list(input().split()) for _ in range(Q)] [0] * (N+1) for _ in range(26) for _ in range(26) _ range(26) range 26 for _ in range(26) [0] * (N+1) [0] 0 N+1 N 1 bit_tree = [[0] * (N+1) for _ in range(26)] bit_tree [[0] * (N+1) for _ in range(26)] def BIT_add(i, tree):
    while i <= N:
        tree[i] += 1
        i += i&(-i) BIT_add while i <= N:
        tree[i] += 1
        i += i&(-i) i <= N i N tree[i] += 1 tree[i] tree i 1 i += i&(-i) i i&(-i) i -i i i i tree tree def BIT_sub(i, tree):
    while i <= N:
        tree[i] -= 1
        i += i&(-i) BIT_sub while i <= N:
        tree[i] -= 1
        i += i&(-i) i <= N i N tree[i] -= 1 tree[i] tree i 1 i += i&(-i) i i&(-i) i -i i i i tree tree def BIT_sum(i, tree):
    s = 0
    while i:
        s += tree[i]
        i -= i&(-i)
    return s BIT_sum s = 0 s 0 while i:
        s += tree[i]
        i -= i&(-i)
     i s += tree[i] s tree[i] tree i i -= i&(-i) i i&(-i) i -i i return s s i i tree tree for i in range(N):
    x = ord(S[i]) - ord('a')
    BIT_add(i + 1, bit_tree[x]) i range(N) range N x = ord(S[i]) - ord('a') x ord(S[i]) - ord('a') ord(S[i]) ord S[i] S i ord('a') ord 'a' BIT_add(i + 1, bit_tree[x]) BIT_add i + 1 i 1 bit_tree[x] bit_tree x for q in range(Q):
    line = q_list[q]
    if line[0] == '1':
        i, c = line[1:]
        i = int(i) - 1
        old_c = ord(S[i]) - ord('a')
        new_c = ord(c) - ord('a')
        BIT_sub(i + 1, bit_tree[old_c])
        BIT_add(i + 1, bit_tree[new_c])
        S[i] = c
    else:
        l, r = map(int, line[1:])
        now = 0
        for i in range(26):
            cnt = BIT_sum(r, bit_tree[i]) - BIT_sum(l - 1, bit_tree[i])
            if cnt > 0:
                now += 1
        print(now) q range(Q) range Q line = q_list[q] line q_list[q] q_list q if line[0] == '1':
        i, c = line[1:]
        i = int(i) - 1
        old_c = ord(S[i]) - ord('a')
        new_c = ord(c) - ord('a')
        BIT_sub(i + 1, bit_tree[old_c])
        BIT_add(i + 1, bit_tree[new_c])
        S[i] = c
    else:
        l, r = map(int, line[1:])
        now = 0
        for i in range(26):
            cnt = BIT_sum(r, bit_tree[i]) - BIT_sum(l - 1, bit_tree[i])
            if cnt > 0:
                now += 1
        print(now) line[0] == '1' line[0] line 0 '1' i, c = line[1:] i line[1:] line 1: 1 c i = int(i) - 1 i int(i) - 1 int(i) int i 1 old_c = ord(S[i]) - ord('a') old_c ord(S[i]) - ord('a') ord(S[i]) ord S[i] S i ord('a') ord 'a' new_c = ord(c) - ord('a') new_c ord(c) - ord('a') ord(c) ord c ord('a') ord 'a' BIT_sub(i + 1, bit_tree[old_c]) BIT_sub i + 1 i 1 bit_tree[old_c] bit_tree old_c BIT_add(i + 1, bit_tree[new_c]) BIT_add i + 1 i 1 bit_tree[new_c] bit_tree new_c S[i] = c S[i] S i c l, r = map(int, line[1:]) l map(int, line[1:]) map int line[1:] line 1: 1 r now = 0 now 0 for i in range(26):
            cnt = BIT_sum(r, bit_tree[i]) - BIT_sum(l - 1, bit_tree[i])
            if cnt > 0:
                now += 1
         i range(26) range 26 cnt = BIT_sum(r, bit_tree[i]) - BIT_sum(l - 1, bit_tree[i]) cnt BIT_sum(r, bit_tree[i]) - BIT_sum(l - 1, bit_tree[i]) BIT_sum(r, bit_tree[i]) BIT_sum r bit_tree[i] bit_tree i BIT_sum(l - 1, bit_tree[i]) BIT_sum l - 1 l 1 bit_tree[i] bit_tree i if cnt > 0:
                now += 1
         cnt > 0 cnt 0 now += 1 now 1 print(now) print now r = map(int, line[1:]) map(int, line[1:]) r INF = 10 ** 18 10 ** 18 INF c = line[1:] line[1:] c now = 0 0 now x = ord(S[i]) - ord('a') ord(S[i]) - ord('a') x i, c = line[1:] line[1:] i N = int(input()) int(input()) N now += 1 1 now read = sys.stdin.buffer.read sys.stdin.buffer.read read readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines q_list = [list(input().split()) for _ in range(Q)] [list(input().split()) for _ in range(Q)] q_list def BIT_add(i, tree):
    while i <= N:
        tree[i] += 1
        i += i&(-i) def BIT_add(i, tree):
    while i <= N:
        tree[i] += 1
        i += i&(-i) BIT_add def BIT_sub(i, tree):
    while i <= N:
        tree[i] -= 1
        i += i&(-i) def BIT_sub(i, tree):
    while i <= N:
        tree[i] -= 1
        i += i&(-i) BIT_sub line = q_list[q] q_list[q] line bit_tree = [[0] * (N+1) for _ in range(26)] [[0] * (N+1) for _ in range(26)] bit_tree S = list(input()) list(input()) S def BIT_sum(i, tree):
    s = 0
    while i:
        s += tree[i]
        i -= i&(-i)
    return s def BIT_sum(i, tree):
    s = 0
    while i:
        s += tree[i]
        i -= i&(-i)
    return s BIT_sum new_c = ord(c) - ord('a') ord(c) - ord('a') new_c cnt = BIT_sum(r, bit_tree[i]) - BIT_sum(l - 1, bit_tree[i]) BIT_sum(r, bit_tree[i]) - BIT_sum(l - 1, bit_tree[i]) cnt Q = int(input()) int(input()) Q MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD old_c = ord(S[i]) - ord('a') ord(S[i]) - ord('a') old_c l, r = map(int, line[1:]) map(int, line[1:]) l i = int(i) - 1 int(i) - 1 i readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
S = list(input())
Q = int(input())
q_list = [list(input().split()) for _ in range(Q)]

bit_tree = [[0] * (N+1) for _ in range(26)]
def BIT_add(i, tree):
    while i <= N:
        tree[i] += 1
        i += i&(-i)

def BIT_sub(i, tree):
    while i <= N:
        tree[i] -= 1
        i += i&(-i)

def BIT_sum(i, tree):
    s = 0
    while i:
        s += tree[i]
        i -= i&(-i)
    return s

for i in range(N):
    x = ord(S[i]) - ord('a')
    BIT_add(i + 1, bit_tree[x])

for q in range(Q):
    line = q_list[q]
    if line[0] == '1':
        i, c = line[1:]
        i = int(i) - 1
        old_c = ord(S[i]) - ord('a')
        new_c = ord(c) - ord('a')
        BIT_sub(i + 1, bit_tree[old_c])
        BIT_add(i + 1, bit_tree[new_c])
        S[i] = c
    else:
        l, r = map(int, line[1:])
        now = 0
        for i in range(26):
            cnt = BIT_sum(r, bit_tree[i]) - BIT_sum(l - 1, bit_tree[i])
            if cnt > 0:
                now += 1
        print(now)