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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        private String s;
        private int n;
        private Pair[] tree;
        private int sz;
        private int L;
        private int R;
        private int pos;
        private char c;
        private boolean[] res;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            s = in.next();
            buildSegmentTree();
            res = new boolean[26];
            int q = in.nextInt();
            L = 1;
            R = sz;
            for (; q > 0; q--) {
                int type = in.nextInt();
                if (type == 1) {
                    pos = in.nextInt() - 1;
                    c = in.next().charAt(0);
                    update();
                } else {
                    int l = in.nextInt();
                    int r = in.nextInt();
                    res = new boolean[26];
                    query(1, l, r, L, R);
                    int ans = 0;
                    for (int j = 0; j < 26; j++)
                        if (res[j]) {
                            ans++;
                        }
                    out.println(ans);
                }
            }
        }

        private void query(int curV, int ql, int qr, int L, int R) {
            int M = (L + R) / 2;
            if (ql == L && qr == R) {
                merge(tree[curV].cnt);
            } else {
                if (ql <= M) {
                    query(2 * curV, ql, Math.min(qr, M), L, M);
                }
                if (qr >= M + 1) {
                    query(2 * curV + 1, Math.max(M + 1, ql), qr, M + 1, R);
                }
            }
        }

        private void update() {
            int charPos = pos + sz;
            tree[charPos] = new Pair(c - 'a');
            int v = pos + sz;
            v /= 2;
            while (v >= 1) {
                tree[v] = new Pair(tree[2 * v].merge(tree[2 * v + 1]));
                v /= 2;
            }
        }

        private void buildSegmentTree() {
            sz = 1;
            while (sz < n)
                sz *= 2;
            if (n == 1)
                sz = 2;
            tree = new Pair[2 * sz];
            for (int i = 0; i < sz; i++) {
                if (i < n)
                    tree[i + sz] = new Pair(s.charAt(i) - 'a');
                else
                    tree[i + sz] = new Pair();
            }
            for (int i = sz - 1; i >= 1; i--) {
                tree[i] = new Pair(tree[2 * i].merge(tree[2 * i + 1]));
            }
        }

        private void merge(boolean[] ar) {
            for (int i = 0; i < 26; i++)
                if (res[i] || ar[i])
                    res[i] = true;
                else
                    res[i] = false;
        }

        private class Pair {
            private int dif;
            private boolean[] cnt;

            public Pair() {
                this.dif = 0;
                this.cnt = new boolean[26];
            }

            public Pair(int pos) {
                this.dif = 1;
                this.cnt = new boolean[26];
                this.cnt[pos] = true;
            }

            public Pair(Pair p) {
                this.dif = p.dif;
                this.cnt = new boolean[26];
                for (int i = 0; i < 26; i++)
                    this.cnt[i] = p.cnt[i];
            }

            public Pair(int dif, boolean[] cnt) {
                this.dif = dif;
                this.cnt = new boolean[26];
                for (int i = 0; i < 26; i++)
                    this.cnt[i] = cnt[i];
            }

            public Pair merge(Pair ex) {
                int diff = 0;
                boolean[] res = new boolean[26];
                for (int i = 0; i < 26; i++)
                    if (this.cnt[i] || ex.cnt[i]) {
                        diff++;
                        res[i] = true;
                    }
                return new Pair(diff, res);
            }

        }

    }

    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());
        }

    }
}

