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

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();
        String str = scanner.nextLine().trim().substring(0, n);
        Fenwick fenwick = new Fenwick(str);
        int q = scanner.nextInt();
        for (int i = 0; i < q; i++) {
            int queryType = scanner.nextInt();
            if(queryType==1){
                int pos = scanner.nextInt();
                char c = scanner.nextLine().trim().charAt(0);
                fenwick.change(pos, c);
            }else{
                int lq = scanner.nextInt();
                int rq = scanner.nextInt();
                System.out.println(fenwick.numberOfDifferentChars(lq, rq));
            }
        }
    }

    public static class Fenwick {
        public static final int abc = 26;
        private char[] str;
        private final int[][] t;
        private final int n;
        public String debugPrint(){
            return new String(str);
        }

        public Fenwick(String string){
            this.str = string.toCharArray();
            n = string.length();
            t = new int[n][abc];
            for (int i = 0; i < n; i++) {
                inc(i,str[i]-'a', 1);
            }
        }
        public void change(int i, char c){
            i=i-1;
            if(str[i]!=c){
                int oldChar = str[i]-'a';
                int newChar = c-'a';
                str[i]=c;
                inc(i, oldChar, -1);
                inc(i, newChar, 1);
            }
        }

        private void inc(int i, int c, int delta){
            for (; i < n; i = (i | (i+1)))
                t[i][c] += delta;
        }

        public int numberOfDifferentChars(int l, int r){
            l--;
            r--;
            int res = 0;
            for (int i = 0; i < abc; i++) {
                if(sum(l, r, i)!=0) res++;
            }
            return res;
        }

        private int sum(int l, int r, int c){
            return sumR(r, c) - sumR(l-1, c);
        }

        private int sumR(int r, int c){
            int result = 0;
            for (; r >= 0; r = (r & (r+1)) - 1)
                result += t[r][c];
            return result;
        }
    }
}