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

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        s = sc.next();
        t = sc.next();
        memo = sc.nextInt2DArr(s.length() + 1, t.length() + 1, -1);
        arr = new ArrayList<>();
        System.out.println(dp(0, 0));
        trace(0, 0);
        for (String s : arr) {
            System.out.println(s);
        }
        pw.close();
    }

    static int[][] memo;
    static ArrayList<String> arr;
    static String s, t;

    // i --> s
    // j --> t
    static int dp(int i, int j) {
        if (j == t.length() && i == s.length()) {
            return 0;
        }
        if (j == t.length()) {
            return s.length() - i;
        }
        if (i == s.length()) {
            return t.length() - j;
        }
        if (memo[i][j] != -1) {
            return memo[i][j];
        }
        if (t.charAt(j) != s.charAt(i)) {
            int insert = 1 + dp(i, j + 1);
            int delete = 1 + dp(i + 1, j);
            int replace = 1 + dp(i + 1, j + 1);
            return memo[i][j] = Math.min(insert, Math.min(delete, replace));
        } else {
            return memo[i][j] = dp(i + 1, j + 1);
        }
    }
    
    static int indexShift = 0;

    static void trace(int i, int j) {
        if (j == t.length() && i == s.length()) {
            return;
        }
        if (j == t.length()) {
            for (int k = i; k < s.length(); k++) {
                arr.add("DELETE " + (i + 1 + indexShift));
            }
            return;
        }
        if (i == s.length()) {
            for (int k = j; k < t.length(); k++) {
                arr.add("INSERT " + (i + 1 + indexShift++) + " " + t.charAt(k));
            }
            return;
        }

        if (t.charAt(j) != s.charAt(i)) {

            if (dp(i, j) == 1 + dp(i, j + 1)) {
                //insert
                arr.add("INSERT " + (i + 1 + indexShift++) + " " + t.charAt(j));
                trace(i, j + 1);
            } else if (dp(i, j) == 1 + dp(i + 1, j)) {
                //delete
                arr.add("DELETE " + (i + 1 + indexShift--));
                trace(i + 1, j);
            } else if (dp(i, j) == 1 + dp(i + 1, j + 1)) {
                //replace
                arr.add("REPLACE " + (i + 1 + indexShift) + " " + t.charAt(j));
                trace(i + 1, j + 1);
            }
            return;
        } else {
            trace(i + 1, j + 1);
        }


    }


    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String file) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

        public long[] nextLongArr(int n) throws IOException {
            long arr[] = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public int[] nextIntArr(int n) throws IOException {
            int arr[] = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public int[] nextIntArr(int n, int f) throws IOException {
            int arr[] = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = f;
            }
            return arr;
        }

        public int[][] nextInt2DArr(int n, int m) throws IOException {
            int arr[][] = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int k = 0; k < m; k++) {
                    arr[i][k] = nextInt();
                }
            }
            return arr;
        }

        public int[][] nextInt2DArr(int n, int m, int f) throws IOException {
            int arr[][] = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int k = 0; k < m; k++) {
                    arr[i][k] = f;
                }
            }
            return arr;
        }

        public String[] nextStringArr(int n) throws IOException {
            String arr[] = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }

        public char[] nextCharArr(int n) throws IOException {
            char arr[] = new char[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next().charAt(0);
            }
            return arr;
        }

    }

    public static long max(long a, long b) {
        return a > b ? a : b;
    }

    public static int min(int a, int b) {
        return a < b ? a : b;
    }
}