import sys
from copy import copy, deepcopy
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
for CASES in range(int(input())):
'''
inf = 100000000000000000  # 1e17
mod = 998244353

'''
# example input


'''


def replace(pos, char):
    x = pos
    old_char = A[x]
    while x <= n:
        tr[x][old_char] -= 1
        x += x & (-x)
    x = pos
    while x <= n:
        tr[x][char] += 1
        x += x & (-x)
    A[pos] = char


def query(pos, char):
    x = pos
    sum = 0
    while x != 0:
        sum += tr[x][char]
        x -= x & (-x)
    return sum


n = int(input())
S = input().strip()
A = [27] * (n + 1)
'''
for i in range(len(S)):
    A.append(ord(S[i])-ord('a'))
'''
tr = [[0] * 30 for i in range(len(S) + 10)]
for i in range(len(S)):
    replace(i + 1, ord(S[i]) - ord('a'))
q = int(input())
for i in range(q):
    QUERY = list((input().split()))
    if int(QUERY[0]) == 1:
        replace(int(QUERY[1]), ord(QUERY[2]) - ord('a'))
    else:
        sum = 0
        for char in range(ord('a'), ord('z') + 1):
            num = query(int(QUERY[2]), char - ord('a')) - \
                query(int(QUERY[1]) - 1, char - ord('a'))
            if num >= 1:
                sum += 1
        print(sum) import sys sys from copy import copy, deepcopy input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline '''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
for CASES in range(int(input())):
''' inf = 100000000000000000 inf 100000000000000000 mod = 998244353 mod 998244353 '''
# example input


''' def replace(pos, char):
    x = pos
    old_char = A[x]
    while x <= n:
        tr[x][old_char] -= 1
        x += x & (-x)
    x = pos
    while x <= n:
        tr[x][char] += 1
        x += x & (-x)
    A[pos] = char replace x = pos x pos old_char = A[x] old_char A[x] A x while x <= n:
        tr[x][old_char] -= 1
        x += x & (-x)
     x <= n x n tr[x][old_char] -= 1 tr[x][old_char] [x] tr x old_char 1 x += x & (-x) x x & (-x) x -x x x = pos x pos while x <= n:
        tr[x][char] += 1
        x += x & (-x)
     x <= n x n tr[x][char] += 1 tr[x][char] [x] tr x char 1 x += x & (-x) x x & (-x) x -x x A[pos] = char A[pos] A pos char pos pos char char def query(pos, char):
    x = pos
    sum = 0
    while x != 0:
        sum += tr[x][char]
        x -= x & (-x)
    return sum query x = pos x pos sum = 0 sum 0 while x != 0:
        sum += tr[x][char]
        x -= x & (-x)
     x != 0 x 0 sum += tr[x][char] sum tr[x][char] [x] tr x char x -= x & (-x) x x & (-x) x -x x return sum sum pos pos char char n = int(input()) n int(input()) int input() input S = input().strip() S input().strip() ().strip () input strip A = [27] * (n + 1) A [27] * (n + 1) [27] 27 n + 1 n 1 '''
for i in range(len(S)):
    A.append(ord(S[i])-ord('a'))
''' [0] * 30 for i in range(len(S) + 10) for i in range(len(S) + 10) i range(len(S) + 10) range len(S) + 10 len(S) len S 10 for i in range(len(S) + 10) [0] * 30 [0] 0 30 tr = [[0] * 30 for i in range(len(S) + 10)] tr [[0] * 30 for i in range(len(S) + 10)] for i in range(len(S)):
    replace(i + 1, ord(S[i]) - ord('a')) i range(len(S)) range len(S) len S replace(i + 1, ord(S[i]) - ord('a')) replace i + 1 i 1 ord(S[i]) - ord('a') ord(S[i]) ord S[i] S i ord('a') ord 'a' q = int(input()) q int(input()) int input() input for i in range(q):
    QUERY = list((input().split()))
    if int(QUERY[0]) == 1:
        replace(int(QUERY[1]), ord(QUERY[2]) - ord('a'))
    else:
        sum = 0
        for char in range(ord('a'), ord('z') + 1):
            num = query(int(QUERY[2]), char - ord('a')) - \
                query(int(QUERY[1]) - 1, char - ord('a'))
            if num >= 1:
                sum += 1
        print(sum) i range(q) range q QUERY = list((input().split())) QUERY list((input().split())) list input().split() ().split () input split if int(QUERY[0]) == 1:
        replace(int(QUERY[1]), ord(QUERY[2]) - ord('a'))
    else:
        sum = 0
        for char in range(ord('a'), ord('z') + 1):
            num = query(int(QUERY[2]), char - ord('a')) - \
                query(int(QUERY[1]) - 1, char - ord('a'))
            if num >= 1:
                sum += 1
        print(sum) int(QUERY[0]) == 1 int(QUERY[0]) int QUERY[0] QUERY 0 1 replace(int(QUERY[1]), ord(QUERY[2]) - ord('a')) replace int(QUERY[1]) int QUERY[1] QUERY 1 ord(QUERY[2]) - ord('a') ord(QUERY[2]) ord QUERY[2] QUERY 2 ord('a') ord 'a' sum = 0 sum 0 for char in range(ord('a'), ord('z') + 1):
            num = query(int(QUERY[2]), char - ord('a')) - \
                query(int(QUERY[1]) - 1, char - ord('a'))
            if num >= 1:
                sum += 1
         char range(ord('a'), ord('z') + 1) range ord('a') ord 'a' ord('z') + 1 ord('z') ord 'z' 1 num = query(int(QUERY[2]), char - ord('a')) - \
                query(int(QUERY[1]) - 1, char - ord('a')) num query(int(QUERY[2]), char - ord('a')) - \
                query(int(QUERY[1]) - 1, char - ord('a')) query(int(QUERY[2]), char - ord('a')) query int(QUERY[2]) int QUERY[2] QUERY 2 char - ord('a') char ord('a') ord 'a' query(int(QUERY[1]) - 1, char - ord('a')) query int(QUERY[1]) - 1 int(QUERY[1]) int QUERY[1] QUERY 1 1 char - ord('a') char ord('a') ord 'a' if num >= 1:
                sum += 1
         num >= 1 num 1 sum += 1 sum 1 print(sum) print sum input = sys.stdin.readline sys.stdin.readline input tr = [[0] * 30 for i in range(len(S) + 10)] [[0] * 30 for i in range(len(S) + 10)] tr inf = 100000000000000000 100000000000000000 inf sum += 1 1 sum S = input().strip() input().strip() S mod = 998244353 998244353 mod sum = 0 0 sum def replace(pos, char):
    x = pos
    old_char = A[x]
    while x <= n:
        tr[x][old_char] -= 1
        x += x & (-x)
    x = pos
    while x <= n:
        tr[x][char] += 1
        x += x & (-x)
    A[pos] = char def replace(pos, char):
    x = pos
    old_char = A[x]
    while x <= n:
        tr[x][old_char] -= 1
        x += x & (-x)
    x = pos
    while x <= n:
        tr[x][char] += 1
        x += x & (-x)
    A[pos] = char replace def query(pos, char):
    x = pos
    sum = 0
    while x != 0:
        sum += tr[x][char]
        x -= x & (-x)
    return sum def query(pos, char):
    x = pos
    sum = 0
    while x != 0:
        sum += tr[x][char]
        x -= x & (-x)
    return sum query n = int(input()) int(input()) n QUERY = list((input().split())) list((input().split())) QUERY num = query(int(QUERY[2]), char - ord('a')) - \
                query(int(QUERY[1]) - 1, char - ord('a')) query(int(QUERY[2]), char - ord('a')) - \
                query(int(QUERY[1]) - 1, char - ord('a')) num A = [27] * (n + 1) [27] * (n + 1) A q = int(input()) int(input()) q
import sys
from copy import copy, deepcopy
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
for CASES in range(int(input())):
'''
inf = 100000000000000000  # 1e17
mod = 998244353

'''
# example input


'''


def replace(pos, char):
    x = pos
    old_char = A[x]
    while x <= n:
        tr[x][old_char] -= 1
        x += x & (-x)
    x = pos
    while x <= n:
        tr[x][char] += 1
        x += x & (-x)
    A[pos] = char


def query(pos, char):
    x = pos
    sum = 0
    while x != 0:
        sum += tr[x][char]
        x -= x & (-x)
    return sum


n = int(input())
S = input().strip()
A = [27] * (n + 1)
'''
for i in range(len(S)):
    A.append(ord(S[i])-ord('a'))
'''
tr = [[0] * 30 for i in range(len(S) + 10)]
for i in range(len(S)):
    replace(i + 1, ord(S[i]) - ord('a'))
q = int(input())
for i in range(q):
    QUERY = list((input().split()))
    if int(QUERY[0]) == 1:
        replace(int(QUERY[1]), ord(QUERY[2]) - ord('a'))
    else:
        sum = 0
        for char in range(ord('a'), ord('z') + 1):
            num = query(int(QUERY[2]), char - ord('a')) - \
                query(int(QUERY[1]) - 1, char - ord('a'))
            if num >= 1:
                sum += 1
        print(sum)
