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

//When I wrote this code, only God & I understood what it did. Now only God knows !!

import java.util.*;
import java.io.*;
import java.math.*;
public class Main implements Runnable {
    @Override
    public void run() {
        FastReader fr = new FastReader();
        PrintWriter pw = new PrintWriter(System.out);
        /*

         */


        pw.flush();
        pw.close();
    }

    static class FastReader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public FastReader() { this(System.in); }public FastReader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String next(){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 long l(){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 int i(){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 double d() throws IOException {return Double.parseDouble(next()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
        public void scanIntArr(int [] arr){ for(int li=0;li<arr.length;++li){ arr[li]=i();}}
        public void scanLongArr(long [] arr){for (int i=0;i<arr.length;++i){arr[i]=l();}}
        public void shuffle(int [] arr){ for(int i=arr.length;i>0;--i) { int r=(int)(Math.random()*i); int temp=arr[i-1]; arr[i-1]=arr[r]; arr[r]=temp; } }
    }

    public static int mod = (int) (1e9 + 7);

    public static BitSet [] tree1;
    public static int[] arr1;
    public static void main(String[] args) throws IOException {
        // new Thread(null,new Main(),"Anything",1<<27).start();

        FastReader fr = new FastReader();
        PrintWriter pw = new PrintWriter(System.out);
        /*
inputCopy
abacaba
5
2 1 4
1 4 b
1 5 b
2 4 6
2 1 7
outputCopy
3
1
2
inputCopy
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
outputCopy
5
2
5
2
6

        */
        char [] arr=fr.nextLine().toCharArray();
        arr1=new int[arr.length];
        for(int i=0;i<arr.length;++i)
            arr1[i]=(int)arr[i];
        int n=arr1.length;
        tree1=new BitSet[4*n];
        for(int i=0;i<4*n;++i)
            tree1[i]=new BitSet(200);
        build(0,n-1,0);
        //System.err.println(tree1[0]);
        int q=fr.i();
        for(int i=0;i<q;++i)
        {
            int type=fr.i();
            if(type==1)
            {
                int pos=fr.i()-1;
                char c=fr.next().charAt(0);
                int value=(int)c;
                update(pos,0,n-1,arr1[pos],value,0);
                arr1[pos]=value;
            }
            else {
                BitSet b1 = query(tree1, fr.i() - 1, fr.i() - 1, 0, 0, n - 1);
                //System.err.println(b1);
                //System.err.println(b1);
                pw.println(b1.cardinality());
            }
        }
        pw.flush();
        pw.close();
    }

    private static void update(int pos, int curL, int curR, int oldValue, int value, int curIndex) {
        if(curL>pos || curR<pos)
            return;
        if(curL==curR)
        {
            tree1[curIndex].clear(oldValue);
            tree1[curIndex].set(value);
            return;
        }
        int mid=(curL+curR)/2;
        update(pos,curL,mid,oldValue,value,2*curIndex+1);
        update(pos,mid+1,curR,oldValue,value,2*curIndex+2);
        tree1[curIndex]=(BitSet)tree1[2*curIndex+1].clone();
        tree1[curIndex].or(tree1[2*curIndex+2]);
    }

    public static BitSet query(BitSet [] tree,int l,int r,int curIndex,int curL,int curR)
    {
        if(curL>=l && curR<=r)
        {
            return (BitSet)tree[curIndex].clone();
        }
        if(curL>r || curR<l)
        {
            return new BitSet();
        }
        int mid=curL+(curR-curL)/2;
        BitSet b1=query(tree,l,r,2*curIndex+1,curL,mid);
        b1.or(query(tree,l,r,2*curIndex+2,mid+1,curR));
        return b1;
    }
    public static void build(int l,int r,int index)
    {
        if(l==r)
        {
            tree1[index].set(arr1[l]);
            return;
        }
        build(l,l+(r-l)/2,2*index+1);
        build(l+(r-l)/2+1,r,2*index+2);
        tree1[index]=(BitSet)tree1[2*index+1].clone();
        tree1[index].or(tree1[2*index+2]);
    }
}
