You are given a string s consisting of lowercase Latin letters and q queries for this string.

Recall that the substring s[l; r] of the string s is the string s_l s_{l + 1} ... s_r. For example, the substrings of "codeforces" are "code", "force", "f", "for", but not "coder" and "top".

There are two types of queries: 

  * 1~ pos~ c (1 ≤ pos ≤ |s|, c is lowercase Latin letter): replace s_{pos} with c (set s_{pos} := c); 
  * 2~ l~ r (1 ≤ l ≤ r ≤ |s|): calculate the number of distinct characters in the substring s[l; r]. 

Input

The first line of the input contains one string s consisting of no more than 10^5 lowercase Latin letters.

The second line of the input contains one integer q (1 ≤ q ≤ 10^5) — the number of queries.

The next q lines contain queries, one per line. Each query is given in the format described in the problem statement. It is guaranteed that there is at least one query of the second type.

Output

For each query of the second type print the answer for it — the number of distinct characters in the required substring in this query.

Examples

Input


abacaba
5
2 1 4
1 4 b
1 5 b
2 4 6
2 1 7


Output


3
1
2


Input


dfcbbcfeeedbaea
15
1 6 e
1 4 b
2 6 14
1 7 b
1 12 c
2 6 8
2 1 6
1 7 c
1 2 f
1 10 a
2 7 9
1 10 a
1 14 b
1 1 f
2 1 11


Output


5
2
5
2
6
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.min;

public class Sol implements Runnable {

  long mod = (long) 1e9 + 7;

  void solve(InputReader in, PrintWriter w) {
    TreeSet<Integer>[] charPos = new TreeSet[26];
    for(int i = 0; i < 26; i++) {
      charPos[i] = new TreeSet<>();
      charPos[i].add((int)1e9);
    }

    char[] c = in.next().toCharArray();
    for(int i = 0; i < c.length; i++) {
      charPos[c[i] - 'a'].add(i + 1);
    }

    int q = in.nextInt();
    while(q-- > 0) {
      int type = in.nextInt();
      if(type == 1) {
        int pos = in.nextInt();
        char cc = in.next().charAt(0);
        char cOld = c[pos - 1];
        c[pos - 1] = cc;
        charPos[cOld - 'a'].remove(pos);
        charPos[cc - 'a'].add(pos);
      } else {
        int l = in.nextInt();
        int r = in.nextInt();
        int res = 0;

        for(int i = 0; i < 26; i++) {
          int nextPos = charPos[i].ceiling(l);
          if(nextPos >= l && nextPos <= r) {
            res++;
          }
        }

        w.println(res);
      }
    }
  }

  // ************* Code ends here ***************

  void init() throws Exception {
    //Scanner in;
    InputReader in;
    PrintWriter w;
    boolean online = false;

    String common_in_fileName = "\\Samplein";
    String common_out_fileName = "\\in";
    int test_files = 0;

    for (int file_no = 0; file_no <= test_files; file_no++) {

      String x = "" + file_no;
      if (x.length() == 1) x = "0" + x;

      String in_fileName = common_in_fileName;// + "" + x;
      String out_fileName = common_out_fileName + "" + x;

      if (online) {
        //in = new Scanner(new File(in_fileName + ".txt"));
        in = new InputReader(new FileInputStream(new File(in_fileName + ".txt")));
        w = new PrintWriter(new FileWriter(out_fileName + ".txt"));
      } else {
        //in = new Scanner(System.in);
        in = new InputReader(System.in);
        w = new PrintWriter(System.out);
      }

      solve(in, w);
      w.close();
    }
  }

  public void run() {
    try {
      init();
    } catch (Exception e) {
      System.out.println(e);
      e.printStackTrace();
    }
  }

  static class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }

      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }

        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public String nextLine() {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

    public int nextInt() {
      int c = read();

      while (isSpaceChar(c)) {
        c = read();
      }

      int sgn = 1;

      if (c == '-') {
        sgn = -1;
        c = read();
      }

      int res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));

      return res * sgn;
    }

    public long nextLong() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      long res = 0;

      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public double nextDouble() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      double res = 0;
      while (!isSpaceChar(c) && c != '.') {
        if (c == 'e' || c == 'E') {
          return res * Math.pow(10, nextInt());
        }
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      }
      if (c == '.') {
        c = read();
        double m = 1;
        while (!isSpaceChar(c)) {
          if (c == 'e' || c == 'E') {
            return res * Math.pow(10, nextInt());
          }
          if (c < '0' || c > '9') {
            throw new InputMismatchException();
          }
          m /= 10;
          res += (c - '0') * m;
          c = read();
        }
      }
      return res * sgn;
    }

    public String readString() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = read();
      } while (!isSpaceChar(c));

      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String next() {
      return readString();
    }

    public interface SpaceCharFilter {

      public boolean isSpaceChar(int ch);
    }
  };

  public static void main(String args[]) throws Exception {
    new Thread(null, new Sol(), "Sol", 1 << 28).start();
  }
}