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

public class test {
  static Reader sc = new Reader();

  public static void main(String[] args) {
    // int t = sc.nextInt();

    // while (t-- > 0) {
    char[] s = sc.next().toCharArray();
    segTree root = new segTree(0, s.length - 1, s);
    int q = sc.nextInt();
    while (q-- > 0) {
      int type = sc.nextInt();
      if (type == 1) {
        int pos = sc.nextInt() - 1;
        int c = sc.next().charAt(0) - 'a';
        root.pointUpdate(pos, c);
      } else {
        int l = sc.nextInt() - 1, r = sc.nextInt() - 1;
        int[] f = root.query(l, r);
        int d = 0;
        for (int i = 0; i < 26; i++) {
          if (f[i] > 0) {
            d++;
          }
        }
        System.out.println(d);
      }
    }

    // }

  }

  static class segTree {
    int val;
    segTree left, right;
    int lidx, ridx;
    int[] freq = new int[26];

    segTree(int leftIdx, int rightIdx, char[] a) {
      lidx = leftIdx;
      ridx = rightIdx;
      // leaf
      if (leftIdx == rightIdx) {
        freq[a[leftIdx] - 'a']++;
        val = 1;
        return;
      }
      int mid = (leftIdx + rightIdx) / 2;
      left = new segTree(leftIdx, mid, a);
      right = new segTree(mid + 1, rightIdx, a);
      merge();
    }

    public void merge() {
      // merge
      for (int i = 0; i < 26; i++) {
        freq[i] = left.freq[i] + right.freq[i];
      }
      // find distinct
      for (int i = 0; i < 26; i++) {
        if (freq[i] > 0) {
          val++;
        }
      }
    }

    public void pointUpdate(int i, int c) {
      if (i < lidx || i > ridx) {
        return;
      }
      if (lidx == ridx) {
        freq = new int[26];
        freq[c]++;
        return;
      }
      int mid = (lidx + ridx) / 2;
      if (i <= mid) {
        left.pointUpdate(i, c);
      } else {
        right.pointUpdate(i, c);
      }
      merge();
    }

    public int[] query(int l, int r) {

      // completely outside
      if (r < lidx || l > ridx) {
        return new int[26];
      }
      // completely in
      if (lidx >= l && ridx <= r) {
        return freq;
      }
      return merged(left.query(l, r), right.query(l, r));
    }

    private int[] merged(int[] f1, int[] f2) {
      int[] f = new int[26];
      for (int i = 0; i < 26; i++) {
        f[i] = f1[i] + f2[i];
      }
      return f;
    }

  }

  static int gcd(int a, int b) {
    if (b == 0)
      return a;
    return gcd(b, a % b);
  }

  static class Reader {
    BufferedReader br;
    StringTokenizer st;

    Reader() {
      br = new BufferedReader(new InputStreamReader(System.in));
      st = new StringTokenizer("");
    }

    Reader(File f) throws FileNotFoundException {
      br = new BufferedReader(new FileReader(f));
      st = new StringTokenizer("");
    }

    String next() {
      while (!st.hasMoreTokens())
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
        }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    int[] nai(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    long[] nal(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }

    char[][] nmc(int n, int m) {
      char[][] map = new char[n][m];
      for (int i = 0; i < n; i++) {
        String str = sc.next();
        for (int j = 0; j < m; j++) {
          map[i][j] = str.charAt(j);
        }
      }
      return map;
    }

    int[][] nmi(int n, int m) {
      int[][] map = new int[n][m];
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          map[i][j] = nextInt();
        }
      }
      return map;
    }

    long[][] nml(int n, int m) {
      long[][] map = new long[n][m];
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          map[i][j] = nextLong();
        }
      }
      return map;
    }
  }

}