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.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        solve();

        in.close();
        out.close();
    }

    static int[][] D;
    static char[] a;
    static char[] b;

    static int d(int i, int j) {
        if (i == 0)
            return j;
        if (j == 0)
            return i;
        if (D[i][j] > 0)
            return D[i][j];
        D[i][j] = Math.min(d(i - 1, j) + 1, d(i, j - 1) + 1);
        D[i][j] = Math.min(D[i][j], d(i - 1, j - 1)
                + (a[i - 1] == b[j - 1] ? 0 : 1));
        return D[i][j];
    }

    static String formatInt(int i) {
        return Integer.toString(i);
    }

    private static void solve() throws Exception {
        a = nextString().toCharArray();
        b = nextString().toCharArray();
        D = new int[a.length + 1][b.length + 1];
        StringBuilder sb = new StringBuilder();
        for (int i = a.length, j = b.length; i > 0 || j > 0;) {
            if (i > 0 && d(i, j) == d(i - 1, j) + 1) {
                sb.append('D');
                --i;
            } else if (j > 0 && d(i, j) == d(i, j - 1) + 1) {
                sb.append('I');
                --j;
            } else {
                if (a[i - 1] != b[j - 1]) {
                    sb.append('C');
                } else {
                    sb.append('M');
                }
                --i;
                --j;
            }
        }
        char[] s = sb.reverse().toString().toCharArray();
        int ar = 0, av = 0, br = 0, insLen = 0;
        out.println(d(a.length, b.length));
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'D') {
                doPrint("DELETE", av + 1 + insLen, a[ar]);
                ++ar;
            } else if (s[i] == 'I') {
                doPrint("INSERT", av + 1 + insLen, b[br]);
                ++br;
                ++insLen;
            } else if (s[i] == 'C') {
                doPrint("REPLACE", av + 1 + insLen, b[br]);
                ++ar;
                ++br;
                ++av;
            } else {
                ++ar;
                ++br;
                ++av;                       
            }
        }

    }

    private static void doPrint(String s, int i, char c) {
        out.print(s);
        out.print(' ');
        out.print(i);
        if (s.charAt(0) != 'D') {
            out.print(' ');
            out.println(c);
        } else {
            out.println();
        }
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer st;

    static String nextString() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }
}