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.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(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, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            StringBuilder s = new StringBuilder(in.next());
            EasySegmentTree[] segTree = new EasySegmentTree[26];
            for (int i = 0; i < 26; i++) {
                segTree[i] = new EasySegmentTree(n);
            }

            for (int i = 0; i < s.length(); i++) {
                segTree[s.charAt(i) - 'a'].update(i, true);
            }

            int m = in.nextInt();
            for (int i = 0; i < m; i++) {
                // out.println(s);
                int t = in.nextInt();
                if (t == 1) {
                    int num = in.nextInt() - 1;
                    String hoge = in.next();
                    segTree[s.charAt(num) - 'a'].update(num, false);
                    s.setCharAt(num, hoge.charAt(0));
                    segTree[s.charAt(num) - 'a'].update(num, true);
                } else {
                    int cnt = 0;
                    int l = in.nextInt();
                    int r = in.nextInt();
                    for (int j = 0; j < 26; j++) {
                        // out.println(segTree[j].query(l - 1, r));
                        if (segTree[j].query(l - 1, r)) {
                            cnt++;
                        }
                    }
                    out.println(cnt);
                }
            }
        }

    }

    static class EasySegmentTree {
        protected ArrayList<Boolean> dat;
        protected int size;

        public EasySegmentTree(int size) {
            setSize(size);
        }

        public void setSize(int size) {
            int sz = 1;
            while (sz < size) {
                sz <<= 1;
            }
            this.size = sz;
            dat = new ArrayList<>();
            for (int i = 0; i < 2 * this.size - 1; i++) {
                dat.add(false);
            }
        }

        public void update(int i, boolean x) {
            i += size - 1;
            dat.set(i, x);
            while (i > 0) {
                i = (i - 1) / 2;
                dat.set(i, dat.get(i * 2 + 1) || dat.get(i * 2 + 2));
            }
        }

        public boolean query(int l, int r) {
            int ll = l + size - 1;
            int rr = r + size - 1;
            boolean res = false;
            while (ll < rr) {
                if ((rr & 1) == 0) {
                    rr--;
                    res = res || dat.get(rr);
                }
                if ((ll & 1) == 0) {
                    res = res || dat.get(ll);
                    ll++;
                }
                ll = (ll - 1) >> 1;
                rr = (rr - 1) >> 1;
            }
            return res;
        }

    }
}

