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
//package com.prituladima.codeforce;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dmytro.prytula prituladima@gmail.com
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        DDistinctCharactersQueries solver = new DDistinctCharactersQueries();
        solver.solve(1, in, out);
        out.close();
    }

    static class DDistinctCharactersQueries {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            char[] s = in.nextToken().toCharArray();
            //build
            final int AL = 'z' - 'a' + 1;

            SumSegmentTree[] segmentTrees = new SumSegmentTree[AL];
            int[][] arr = new int[AL][s.length];
            for (int i = 0; i < AL; i++) {
                for (int j = 0; j < s.length; j++) {
                    if (s[j] == liter(i)) {
                        arr[i][j] = 1;
                    }
                }
                segmentTrees[i] = new SumSegmentTree(arr[i]);
            }

            int t = in.nextInt();
            for (int i = 0; i < t; i++) {
                int type = in.nextInt();
                if (type == 1) {
                    int pos = in.nextInt() - 1;
                    char c = in.nextToken().charAt(0);
                    char toReplace = s[pos];
                    s[pos] = c;


                    segmentTrees[ind(toReplace)].update(pos, 0);
                    segmentTrees[ind(c)].update(pos, 1);
                } else if (type == 2) {
                    int l = in.nextInt() - 1;
                    int r = in.nextInt() - 1;
                    int ans = 0;
                    for (int j = 0; j < AL; j++) {
                        final int sum = segmentTrees[j].sum(l, r);
                        if (sum > 0) {
                            ans++;
                        }
                    }
                    out.printFormat("%d\n", ans);
                }
            }

        }

        private int ind(char cChar) {
            return cChar - 'a';
        }

        private char liter(int ind) {
            return (char) ('a' + ind);
        }

    }

    static class SumSegmentTree {
        private int n;
        private int[] t;

        public SumSegmentTree(int[] a) {
            n = a.length;
            t = new int[4 * n];
            build(a, 1, 0, n - 1);
        }

        public int sum(int l, int r) {
            return sum(1, 0, n - 1, l, r);
        }

        public void update(int pos, int new_val) {
            update(1, 0, n - 1, pos, new_val);
        }

        private void build(int a[], int v, int tl, int tr) {
            if (tl == tr)
                t[v] = a[tl];
            else {
                int tm = (tl + tr) / 2;
                build(a, v * 2, tl, tm);
                build(a, v * 2 + 1, tm + 1, tr);
                t[v] = t[v * 2] + t[v * 2 + 1];
            }
        }

        private int sum(int v, int tl, int tr, int l, int r) {
            if (l > r)
                return 0;
            if (l == tl && r == tr)
                return t[v];
            int tm = (tl + tr) / 2;
            return sum(v * 2, tl, tm, l, Math.min(r, tm))
                    + sum(v * 2 + 1, tm + 1, tr, Math.max(l, tm + 1), r);
        }

        private void update(int v, int tl, int tr, int pos, int new_val) {
            if (tl == tr)
                t[v] = new_val;
            else {
                int tm = (tl + tr) / 2;
                if (pos <= tm)
                    update(v * 2, tl, tm, pos, new_val);
                else
                    update(v * 2 + 1, tm + 1, tr, pos, new_val);
                t[v] = t[v * 2] + t[v * 2 + 1];
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

        private 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 int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public String nextToken() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        private static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public OutputWriter printFormat(String format, Object... objects) {
            writer.printf(format, objects);
            return this;
        }

        public void close() {
            writer.close();
        }

    }
}

