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

class UpdateSingleGetRangeSegmentTree<T> {
  interface Operator<T> {
    T update(T originalValue, T argumentValue);
    T merge(T smallValue, T largeValue);
    T getUnitValue();
  }
  
  private final Operator<T> operator;
  private final int n;
  private final List<T> values;
  
  UpdateSingleGetRangeSegmentTree(Operator<T> operator, T[] initialValues) {
    this.operator = operator;
    
    int tempN = 1;
    while (tempN < initialValues.length) {
      tempN *= 2;
    }
    n = tempN;
    values = new ArrayList<>();
    for (int i = 0; i < 2 * n - 1; i++) {
      values.add(null);
    }
    for (int i = 0; i < initialValues.length; i++) {
      values.set(i + n - 1, initialValues[i]);
    }
    for (int i = initialValues.length; i < n; i++) {
      values.set(i + n - 1, this.operator.getUnitValue());
    }
    
    for (int i = n - 2; i >= 0; i--) {
      values.set(i, this.operator.merge(values.get(2 * i + 1), values.get(2 * i + 2)));
    }
  }
  
  public void update(int index, T argumentValue) {
    index += n - 1;
    values.set(index, operator.update(values.get(index), argumentValue));
    while (index > 0) {
      index = (index - 1) / 2;
      values.set(index, this.operator.merge(values.get(2 * index + 1), values.get(2 * index + 2)));
    }
  }
  
  private T getRange(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
      return operator.getUnitValue();
    }
    if (a <= l && r <= b) {
      return values.get(k);
    }
    T vl = getRange(a, b, 2 * k + 1, l, (l + r) / 2);
    T vr = getRange(a, b, 2 * k + 2, (l + r) / 2, r);
    return operator.merge(vl, vr);
  }
  
  public T getRange(int a, int b) {
    return getRange(a, b, 0, 0, n);
  }
}

class Solver {
  final int n, q;
  final char[] cs;
  final String[][] queries;
  
  Solver(int n, char[] cs, int q, String[][] queries) {
    this.n = n;
    this.cs = cs;
    this.q = q;
    this.queries = queries;
  }
  
  private int countBit(int bitset) {
    int count = 0;
    while (bitset > 0) {
      count += bitset & 1;
      bitset >>= 1;
    }
    return count;
  }
  
  public List<Integer> solve() {
    UpdateSingleGetRangeSegmentTree.Operator<Integer> operator = new UpdateSingleGetRangeSegmentTree.Operator<Integer>() {
      public Integer update(Integer originalValue, Integer argumentValue) {
        return argumentValue;
      }
      public Integer merge(Integer smallValue, Integer largeValue) {
        return smallValue | largeValue;
      }
      private final Integer ZERO = Integer.valueOf(0);
      public Integer getUnitValue() {
        return ZERO;
      }
    };
    Integer[] values = new Integer[n];
    for (int j = 0; j < n; j++) {
      values[j] = 1 << (cs[j] - 'a');
    }
    UpdateSingleGetRangeSegmentTree<Integer> segmentTree = new UpdateSingleGetRangeSegmentTree<>(operator, values);
    
    List<Integer> answers = new ArrayList<>();
    for (String[] query : queries) {
      if ("1".equals(query[0])) {
        int i = Integer.parseInt(query[1]);
        char c = query[2].charAt(0);
        segmentTree.update(i - 1, 1 << (c - 'a'));
      } else if ("2".equals(query[0])) {
        int l = Integer.parseInt(query[1]);
        int r = Integer.parseInt(query[2]);
        answers.add(countBit(segmentTree.getRange(l - 1, r)));
      } else {
        throw new RuntimeException();
      }
    }
    return answers;
  }
}

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    char[] cs = reader.nextCharArray();
    int q = reader.nextInt();
    String[][] queries = reader.next(q, 3);
    for (int answer : new Solver(n, cs, q, queries).solve()) {
      out.println(answer);
    }
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private static final int BUFFER_SIZE = 1024;
  
  private final InputStream stream;
  private final byte[] buffer;
  private int pointer;
  private int bufferLength;
  
  ContestReader(InputStream stream) {
    this.stream = stream;
    this.buffer = new byte[BUFFER_SIZE];
    this.pointer = 0;
    this.bufferLength = 0;
  }
  
  private boolean hasNextByte() {
    if (pointer < bufferLength) {
      return true;
    }
    
    pointer = 0;
    try {
      bufferLength = stream.read(buffer);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    return bufferLength > 0;
  }
  
  private int readByte() {
    if (hasNextByte()) {
      return buffer[pointer++];
    } else {
      return -1;
    }
  }
  
  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }
  
  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[pointer])) {
      pointer++;
    }
    return hasNextByte();
  }
  
  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    while(true) {
      int b = readByte();
      if (!isPrintableChar(b)) {
        break;
      }
      sb.appendCodePoint(b);
    }
    return sb.toString();
  }
  
  public char nextChar() {
    return next().charAt(0);
  }
  
  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    
    int n = 0;
    boolean minus = false;
    
    {
      int b = readByte();
      if (b == '-') {
        minus = true;
      } else if ('0' <= b && b <= '9') {
        n = b - '0';
      } else {
        throw new NumberFormatException();
      }
    }
    
    while(true){
      int b = readByte();
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
    }
  }
  
  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    
    long n = 0;
    boolean minus = false;
    
    {
      int b = readByte();
      if (b == '-') {
        minus = true;
      } else if ('0' <= b && b <= '9') {
        n = b - '0';
      } else {
        throw new NumberFormatException();
      }
    }
    
    while(true){
      int b = readByte();
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
    }
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public char[] nextChar(int n) {
    char[] array = new char[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextChar();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public String[][] next(int n, int m) {
    String[][] matrix = new String[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = next();
      }
    }
    return matrix;
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public char[][] nextChar(int n, int m) {
    char[][] matrix = new char[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextChar();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}
