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 D implements Runnable {

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer tok = new StringTokenizer("");

    private void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);
        String fileName = "";
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

    String readString() {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() {
        return Integer.parseInt(readString());
    }

    long readLong() {
        return Long.parseLong(readString());
    }

    double readDouble() {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int size) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = readInt();
        }
        return a;
    }

    public static void main(String[] args) {
        //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
        new D().run();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    @Override
    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int n, m;
    Point[][] parent;

    class Point {
        int i, j;

        public Point(int i, int j) {
            this.i = i;
            this.j = j;
        }
    }

    void update(int[][] dp, int i, int j, int value, int fromI, int fromJ) {
        if (i < 0 || i >= n + 1 || j < 0 || j >= m + 1) {
            return;
        }
        if (dp[i][j] > value) {
            dp[i][j] = value;
            parent[i][j] = new Point(fromI, fromJ);
        }
    }

    final static String INSERT = "INSERT ";
    final static String DELETE = "DELETE ";
    final static String REPLACE = "REPLACE ";

    class Query {
        String type;
        int pos;
        char ch;

        public Query(String type, int pos, char ch) {
            this.type = type;
            this.pos = pos;
            this.ch = ch;
        }

        @Override
        public String toString() {
            return type + pos + (type == DELETE ? "" : " " + ch);
        }
    }

    private void solve() {
        char[] s = readString().toCharArray();
        n = s.length;
        char[] t = readString().toCharArray();
        m = t.length;
        int[][] dp = new int[n + 1][m + 1];
        parent = new Point[n + 1][m + 1];
        for (int i = 0; i < n + 1; i++) {
            Arrays.fill(dp[i], Integer.MAX_VALUE / 2);
        }

        for (int i = 0; i <= n; i++) {
            dp[i][0] = i;
            parent[i][0] = new Point(i - 1, 0);
        }
        for (int j = 0; j <= m; j++) {
            dp[0][j] = j;
            parent[0][j] = new Point(0, j - 1);
        }

        dp[0][0] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                update(dp, i, j, dp[i - 1][j] + 1, i - 1, j); // insert
                update(dp, i, j, dp[i][j - 1] + 1, i, j - 1); // delete
                update(dp, i, j, dp[i - 1][j - 1] + (s[i - 1] == t[j - 1] ? 0 : 1), i - 1, j - 1); // replace
            }
        }
        out.println(dp[n][m]);
        List<Query> queries = new ArrayList<>();
        int curI = n;
        int curJ = m;
        while (queries.size() < dp[n][m]) {
            int prevI = parent[curI][curJ].i;
            int prevJ = parent[curI][curJ].j;
            if (prevI == curI - 1 && prevJ == curJ - 1) {
                if (s[curI - 1] != t[curJ - 1]) {
                    queries.add(new Query(REPLACE, curJ, t[curJ - 1]));
                }
            } else if (prevI == curI - 1) {
                queries.add(new Query(DELETE, curJ + 1, 'a'));
            } else {
                queries.add(new Query(INSERT, curJ, t[curJ - 1]));
            }
            curI = prevI;
            curJ = prevJ;
        }
        Collections.reverse(queries);
        for (Query q : queries) {
            out.println(q);
        }
    }
}