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

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

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s1 = in.next();
            String s2 = in.next();
            int n = s1.length();
            int m = s2.length();
            int[][] f = new int[n + 2][m + 2];
            int[][] wasI = new int[n + 2][m + 2];
            int[][] wasJ = new int[n + 2][m + 2];
            int[][] type = new int[n + 2][m + 2];
            char[][] added = new char[n + 2][m + 2];
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= m; j++) {
                    f[i][j] = Integer.MAX_VALUE;
                }
            }
            f[0][0] = 0;
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= m; j++) {
                    if (f[i][j] == Integer.MAX_VALUE) {
                        continue;
                    }
                    if (i == n && j == m) {
                        continue;
                    }
                    if (j == m) {
                        if (f[i + 1][j] > f[i][j] + 1) {
                            f[i + 1][j] = f[i][j] + 1;
                            wasI[i + 1][j] = i;
                            wasJ[i + 1][j] = j;
                            type[i + 1][j] = 2;
                            added[i + 1][j] = '$';
                        }
                        continue;
                    }
                    if (i == n) {
                        if (f[i][j + 1] > f[i][j] + 1) {
                            f[i][j + 1] = f[i][j] + 1;
                            wasI[i][j + 1] = i;
                            wasJ[i][j + 1] = j;
                            type[i][j + 1] = 1;
                            added[i + 1][j + 1] = s2.charAt(j);
                        }
                        continue;
                    }
                    char c1 = s1.charAt(i);
                    char c2 = s2.charAt(j);
                    if (c1 == c2) {
                        if (f[i + 1][j + 1] > f[i][j]) {
                            f[i + 1][j + 1] = f[i][j];
                            wasI[i + 1][j + 1] = i;
                            wasJ[i + 1][j + 1] = j;
                            type[i + 1][j + 1] = -1;
                            added[i + 1][j + 1] = '$';
                        }
                    }
                    if (f[i + 1][j] > f[i][j] + 1) {
                        f[i + 1][j] = f[i][j] + 1;
                        wasI[i + 1][j] = i;
                        wasJ[i + 1][j] = j;
                        type[i + 1][j] = 2;
                        added[i + 1][j] = '$';
                    }
                    if (f[i + 1][j + 1] > f[i][j] + 1) {
                        f[i + 1][j + 1] = f[i][j] + 1;
                        wasI[i + 1][j + 1] = i;
                        wasJ[i + 1][j + 1] = j;
                        type[i + 1][j + 1] = 3;
                        added[i + 1][j + 1] = c2;
                    }
                    if (f[i][j + 1] > f[i][j] + 1) {
                        f[i][j + 1] = f[i][j] + 1;
                        wasI[i][j + 1] = i;
                        wasJ[i][j + 1] = j;
                        type[i][j + 1] = 1;
                        added[i][j + 1] = c2;
                    }
                }
            }
            int result = f[n][m];
            String[] commands = new String[result];
            int[] positions = new int[result];
            char[] characters = new char[result];
            int id = 0;
            int x = n;
            int y = m;
            while (true) {
                if (x == 0 && y == 0) {
                    break;
                }
                int newX = wasI[x][y];
                int newY = wasJ[x][y];
                if (type[x][y] == -1) {
                    x = newX;
                    y = newY;
                    continue;
                }
                if (type[x][y] == 1) {
                    commands[id] = "INSERT";
                    positions[id] = newY + 1;
                    characters[id++] = added[x][y];
                    x = newX;
                    y = newY;
                    continue;
                }
                if (type[x][y] == 2) {
                    commands[id] = "DELETE";
                    positions[id] = newY + 1;
                    characters[id++] = '$';
                    x = newX;
                    y = newY;
                    continue;
                }
                if (type[x][y] == 3) {
                    commands[id] = "REPLACE";
                    positions[id] = newY + 1;
                    characters[id++] = added[x][y];
                    x = newX;
                    y = newY;
                    continue;
                }
            }
            out.println(result);
            for (int i = result - 1; i >= 0; --i) {
                out.print(commands[i] + " ");
                out.print(positions[i]);
                if (characters[i] == '$') {
                    out.println("");
                    continue;
                }
                int code = characters[i] - (int) ('A');
                if (code >= 0 && code < 26)
                    out.println(" " + characters[i]);
                else {
                    System.exit(228);
                    return;
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}