Problem: There is a string s, consisting of capital Latin letters. Let's denote its current length as |s|. During one move it is allowed to apply one of the following operations to it: 

  * INSERT pos ch — insert a letter ch in the string s in the position pos (1 ≤ pos ≤ |s| + 1, A ≤ ch ≤ Z). The letter ch becomes the pos-th symbol of the string s, at that the letters shift aside and the length of the string increases by 1. 
  * DELETE pos — delete a character number pos (1 ≤ pos ≤ |s|) from the string s. At that the letters shift together and the length of the string decreases by 1. 
  * REPLACE pos ch — the letter in the position pos of the line s is replaced by ch (1 ≤ pos ≤ |s|, A ≤ ch ≤ Z). At that the length of the string does not change. 



Your task is to find in which minimal number of moves one can get a t string from an s string. You should also find the sequence of actions leading to the required results.

Input

The first line contains s, the second line contains t. The lines consist only of capital Latin letters, their lengths are positive numbers from 1 to 1000.

Output

In the first line print the number of moves k in the given sequence of operations. The number should be the minimal possible one. Then print k lines containing one operation each. Print the operations in the format, described above. If there are several solutions, print any of them.

Examples

Input

ABA
ABBBA


Output

2
INSERT 3 B
INSERT 4 B


Input

ACCEPTED
WRONGANSWER


Output

10
REPLACE 1 W
REPLACE 2 R
REPLACE 3 O
REPLACE 4 N
REPLACE 5 G
REPLACE 6 A
INSERT 7 N
INSERT 8 S
INSERT 9 W
REPLACE 11 R

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        //Scanner sc = new Scanner();
        Reader in = new Reader();
        Main solver = new Main();
        solver.solve(out, in);
        out.flush();
        out.close();
 
    }
 
    //<>
    // 
    
    static int maxn = (int)1e5*2;
    static long mod=998244353 ;
    static int n,m,k;
    
    static int INF = 1000000001;
    
    void solve(PrintWriter out, Reader in) throws IOException{   
        String s = in.next();
        String t = in.next();
        
        int[][] dp = new int[1005][1005];
        Node[][] prev = new Node[1005][1005];
        for(int i=0;i<=1000;i++)
            for(int j=0;j<=1000;j++)
                dp[i][j] = maxn;
        
        dp[0][0]=0;
        
        for(int i=0;i<=t.length();i++){
            for(int j=0;j<=s.length();j++){
                if(dp[i][j]!=maxn){
                    if(j!=s.length() && i!=t.length() && t.charAt(i)==s.charAt(j) && dp[i][j]<dp[i+1][j+1]){
                        dp[i+1][j+1] = dp[i][j];
                        prev[i+1][j+1] = new Node('R','R',0,i,j);
                    }
                        
                    if(dp[i][j]+1<dp[i+1][j+1] && i!=t.length()){
                        dp[i+1][j+1] = dp[i][j]+1;
                        prev[i+1][j+1] = new Node('R',t.charAt(i),i+1,i,j);
                    }
                     
                    if(dp[i][j]+1<dp[i+1][j] && i!=t.length()) {
                        dp[i+1][j] = dp[i][j]+1;
                        prev[i+1][j] = new Node('I',t.charAt(i),i+1,i,j);
                    }
                    
                    if(dp[i][j]+1<dp[i][j+1]) {
                        dp[i][j+1] = dp[i][j]+1;
                        prev[i][j+1] = new Node('D','A',i+1,i,j);
                    }
                }
            }
        }
        
        out.println(dp[t.length()][s.length()]);
        
        Stack<Node> st = new Stack<>();
        
        int a=t.length(),b=s.length();
        
        while(a!=0 || b!=0){
            
            Node temp = prev[a][b];
            if(temp.idx!=0) {
                if(temp.print=='R'){
                    st.push(new Node("REPLACE",temp.idx,temp.ch));
                }else if(temp.print=='I'){
                    st.push(new Node("INSERT",temp.idx,temp.ch));
                }else{
                    st.add(new Node("DELETE",temp.idx,'A'));
                }
            }
            a = temp.x;
            b = temp.y;
        }
        
        while(st.size()!=0){
            Node temp = st.pop();
            if(temp.str.equals("DELETE")){
                out.println(temp.str+" "+temp.idx);
            }else out.println(temp.str+" "+temp.idx+" "+temp.ch);
        }
    }
    
    
    static class Node {
        char print,ch;
        int idx,x,y;
        String str;
        
        Node(char print,char ch,int idx,int x,int y){
            this.x = x;
            this.y = y;
            this.idx = idx;
            this.ch = ch;
            this.print = print;
        }
        
        Node(String str,int idx,char ch){
            this.str = str;
            this.ch = ch;
            this.idx = idx;
        }
        
    }
    
    static class Edge {
        int d,w;
        
        Edge(int d,int w){
            this.d = d;
            this.w = w;
        }
    }
    
    
    static class Reader {
 
        private InputStream mIs;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
 
        public Reader() {
            this(System.in);
        }
 
        public Reader(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();
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        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 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 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;
        }
 
    }
}