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.InputMismatchException;
import java.io.*;
import java.util.Vector;
import java.util.Collections;
import java.util.Arrays;

/**
 * Generated by Contest helper plug-in
 * Actual solution is at the bottom
 */
public class Main {
    public static void main(String[] args) {
        InputReader in = new StreamInputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        run(in, out);
    }

    public static void run(InputReader in, PrintWriter out) {
        Solver solver = new EditDistanec();
        solver.solve(1, in, out);
        Exit.exit(in, out);
    }
}

class StreamInputReader extends InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar, numChars;

    public StreamInputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    @Override
    public void close() {
        try {
            stream.close();
        } catch (IOException ignored) {
        }
    }
}

abstract class InputReader {
    private boolean finished = false;

    public abstract int read();


    public String nextToken() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public void setFinished(boolean finished) {
        this.finished = finished;
    }

    public abstract void close();
}

interface Solver {
    public void solve(int testNumber, InputReader in, PrintWriter out);
}

class Exit {
    private Exit() {
    }

    public static void exit(InputReader in, PrintWriter out) {
        in.setFinished(true);
        in.close();
        out.close();
    }
}

class EditDistanec implements Solver {
    static final int DELETE = 0;
    static final int INSERT = 1;
    static final int CHANGE = 2;
    static final int NOTHING = 3;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        char[] s0 = ("#" + in.nextToken()).toCharArray();
        char[] s1 = ("#" + in.nextToken()).toCharArray();
        int n = s0.length;
        int m = s1.length;
        int[][] dm = new int[n][m];
        int[][] doit = new int[n][m];
        int[][] p0 = new int[n][m];
        int[][] p1 = new int[n][m];
        char[][] ch = new char[n][m];
        int[][] pos = new int[n][m];
        for (int c[] : dm)
            Arrays.fill(c, Integer.MAX_VALUE / 2);
        dm[0][0] = 0;
        for (int pref0 = 0; pref0 < n; ++pref0)
            for (int pref1 = 0; pref1 < m; ++pref1) {
                if (pref0 == 0 && pref1 == 0) continue;
                int res = Integer.MAX_VALUE / 10, d = -1, pp0 = -1, pp1 = -1, pp = -1;
                char cha = 0;

                if (s0[pref0] == s1[pref1] && pref0 - 1 >= 0 && pref1 - 1 >= 0) {
                    int ndist = dm[pref0 - 1][pref1 - 1];
                    if (res > ndist) {
                        res = ndist;
                        d = NOTHING;
                        pp0 = pref0 - 1;
                        pp1 = pref1 - 1;
                    }
                }
                int ndist = -1;
                if (pref1 - 1 >= 0) {
                    ndist = dm[pref0][pref1 - 1] + 1;
                    if (res > ndist) {
                        res = ndist;
                        d = INSERT;
                        pp0 = pref0;
                        pp1 = pref1 - 1;
                        cha = s1[pref1];
                        pp = pref1;
                    }
                }
                if (pref0 - 1 >= 0) {
                    ndist = dm[pref0 - 1][pref1] + 1;
                    if (res > ndist) {
                        res = ndist;
                        d = DELETE;
                        pp0 = pref0 - 1;
                        pp1 = pref1;
                        cha = s0[pref0];
                        pp = pref1 + 1;
                    }
                }
                if (pref0 - 1 >= 0 && pref1 - 1 >= 0) {
                    ndist = dm[pref0 - 1][pref1 - 1] + 1;
                    if (res > ndist) {
                        res = ndist;
                        d = CHANGE;
                        pp0 = pref0 - 1;
                        pp1 = pref1 - 1;
                        cha = s1[pref1];
                        pp = pref1;
                    }
                }
                dm[pref0][pref1] = res;
                p0[pref0][pref1] = pp0;
                p1[pref0][pref1] = pp1;
                ch[pref0][pref1] = cha;
                pos[pref0][pref1] = pp;
                doit[pref0][pref1] = d;
            }
        out.println(dm[n - 1][m - 1]);
        int cn = n - 1, cm = m - 1;
        Vector<Pair> path = new Vector<Pair>() ;
        while (cn > 0 || cm > 0) {
            int pcn = p0[cn][cm];
            int pcm = p1[cn][cm];
            int d = doit[cn][cm];
            char cha = ch[cn][cm];
            int pp = pos[cn][cm];
            if (d == INSERT) path.add(new Pair("INSERT", pp, cha));
            else if (d == DELETE) path.add(new Pair("DELETE", pp, cha));
            else if (d == CHANGE) path.add(new Pair("REPLACE", pp, cha));
            cn = pcn;
            cm = pcm;
        }
        Collections.reverse(path);
        for (Pair pair : path) {
            out.print(pair + "\n");
        }

    }
    class Pair {
        String event ;
        int pos;
        char ch;

        Pair(String event, int pos, char ch) {
            this.event = event;
            this.pos = pos;
            this.ch = ch;
        }

        @Override
        public String toString() {
            if (event.equals("DELETE")) {
                return event + " " + Integer.toString(pos) ;
            }
            return event + " " + Integer.toString(pos) + " " + Character.toString(ch);
        }
    }
}