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
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ESimpleStringQueries solver = new ESimpleStringQueries();
        solver.solve(1, in, out);
        out.close();
    }

    static class ESimpleStringQueries {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            StringBuilder x = new StringBuilder(in.next());
            SegmentT st[] = new SegmentT[26];
            for (int i = 0; i < 26; i++) {
                long a[] = new long[n];
                for (int j = 0; j < n; j++) {
                    if (x.charAt(j) == ('a' + i)) {
                        a[j] = 1;
                    } else {
                        a[j] = 0;
                    }
                }
                st[i] = new SegmentT(a);
            }
            int q = in.nextInt();
            while (q-- > 0) {
                int t = in.nextInt();
                if (t == 1) {
                    int indi = in.nextInt() - 1;
                    Character c = in.next().charAt(0);
                    if (x.charAt(indi) != c) {
                        st[c - 'a'].add(indi, 1);
                        st[x.charAt(indi) - 'a'].add(indi, -1);
                    }
                    x.setCharAt(indi, c);
                } else {
                    int l = in.nextInt() - 1;
                    int r = in.nextInt() - 1;
                    int ans = 0;
                    for (int i = 0; i < 26; i++) {
                        if (st[i].get(l, r + 1) > 0) {
                            ans++;
                        }
                    }
                    out.println(ans);
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class SegmentT {
        int n;
        long[] node;

        public SegmentT(int size) {
            n = 1;
            while (n < size) n <<= 1;
            node = new long[2 * n - 1];
            Arrays.fill(node, 0);
        }

        public SegmentT(long[] a) {
            n = 1;
            while (n < a.length) n <<= 1;
            node = new long[2 * n - 1];
            System.arraycopy(a, 0, node, n - 1, a.length);
            Arrays.fill(node, n - 1 + a.length, 2 * n - 1, 0);
            for (int i = n - 2; i >= 0; i--) {
                node[i] = node[i * 2 + 1] + node[i * 2 + 2];
            }
        }

        long value(long x, long y) {
            return x + y;
        }

        void add(int i, int x) {
            i += n - 1;
            node[i] += x;
            while (i > 0) {
                i = (i - 1) / 2;
                node[i] = node[i * 2 + 1] + node[i * 2 + 2];
            }
        }

        long get(int l, int r) {
            return getValue(l, r, 0, 0, n);
        }

        long getValue(int a, int b, int k, int l, int r) {
            if (r <= a || b <= l) return 0;
            if (a <= l && r <= b) return node[k];
            long vl = getValue(a, b, k * 2 + 1, l, (l + r) / 2);
            long vr = getValue(a, b, k * 2 + 2, (l + r) / 2, r);
            return value(vl, vr);
        }

    }
}

