You are given a string S of length N consisting of lowercase English letters.

Process Q queries of the following two types:

* Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)
* Type 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).

Constraints

* N, Q, i_q, l_q, and r_q are integers.
* S is a string consisting of lowercase English letters.
* c_q is a lowercase English letter.
* 1 \leq N \leq 500000
* 1 \leq Q \leq 20000
* |S| = N
* 1 \leq i_q \leq N
* 1 \leq l_q \leq r_q \leq N
* There is at least one query of type 2 in each testcase.

Input

Input is given from Standard Input in the following format:


N
S
Q
Query_1
\vdots
Query_Q


Here, Query_i in the 4-th through (Q+3)-th lines is one of the following:


1 i_q c_q



2 l_q r_q


Output

For each query of type 2, print a line containing the answer.

Example

Input

7
abcdbbd
6
2 3 6
1 5 z
2 1 1
1 4 a
1 7 d
2 1 7


Output

3
1
5
from sys import stdin

d = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

input = stdin.readline

n = int(input())

tree = [[0] * n * 2 for _ in range(26)]

def build(arr):
    for i in range(n):
        tree[ddd][n + i] = arr[i]

    for i in range(n - 1, 0, -1):
        tree[ddd][i] = tree[ddd][i << 1] + tree[ddd][i << 1 | 1]

def update(p, value):
    p += n
    tree[ddd][p] = value

    i = p

    while i > 1:
        tree[ddd][i >> 1] = tree[ddd][i] + tree[ddd][i ^ 1]
        i >>= 1

def query(l, r):
    res = 0

    l += n
    r += n

    while l < r:

        if l & 1:
            res += tree[ddd][l]
            l += 1

        if r & 1:
            r -= 1
            res += tree[ddd][r]

        l >>= 1
        r >>= 1

    return res

s = list(input())

arrs = [[0] * n for _ in range(26)]

for i in range(n):
    arrs[d[s[i]]][i] = 1

for ddd in range(26):
    build(arrs[ddd])

for _ in range(int(input())):
    t = input().split()

    if t[0] == '1':
        i, c = t[1:]
        i = int(i) - 1

        new = d[c]
        cur = d[s[i]]

        s[i] = c

        ddd = cur
        update(i, 0)

        ddd = new
        update(i, 1)

    if t[0] == '2':
        l, r = map(int, t[1:])
        l -= 1
        r -= 1

        ans = 0

        for ddd in range(26):
            if query(l, r + 1) != 0:
                ans += 1

        print(ans)