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

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

class TaskD {
    public void solve(int testNumber, Reader in, PrintWriter out) {
        String s = in.rl();
        String t = in.rl();
        int n, m;
        n = s.length();
        m = t.length();
        int[][] dp = new int[n][m];
        for(int i = 0; i < n; i++) {
            Arrays.fill(dp[i], Integer.MAX_VALUE);
        }
        boolean met = false;
        for(int i = 0; i < m; i++) {
            if(s.charAt(0) == t.charAt(i)) {
                met = true;
            }
            if(met) {
                dp[0][i] = i;
            } else {
                dp[0][i] = i + 1;
            }
        }
        met = false;
        for(int i = 0; i < n; i++) {
            if(s.charAt(i) == t.charAt(0)) {
                met = true;
            }
            if(met) {
                dp[i][0] = Math.min(dp[i][0], i);
            } else {
                dp[i][0] = Math.min(dp[i][0], i + 1);
            }
        }
        int[][] op = new int[n][m];
        for(int i = 1; i < n; i++) {
            for(int j = 1; j < m; j++) {
                if(s.charAt(i) == t.charAt(j)) {
                    dp[i][j] = dp[i - 1][j - 1];
                    op[i][j] = 0;
                } else {
                    if(dp[i][j] > dp[i - 1][j - 1] + 1) {
                        dp[i][j] = dp[i - 1][j - 1] + 1;
                        op[i][j] = 1;
                    }
                }
                if(dp[i][j] > dp[i - 1][j] + 1) {
                    dp[i][j] = dp[i - 1][j] + 1;
                    op[i][j] = 2;
                }
                if(dp[i][j] > dp[i][j - 1] + 1) {
                    dp[i][j] = dp[i][j - 1] + 1;
                    op[i][j] = 3;
                }
            }
        }
        int x = n - 1; int y = m - 1;
        ArrayDeque<String> q = new ArrayDeque<>();
        while(x != 0 && y != 0) {
            switch(op[x][y]) {
                case 0:
                    --x;
                    --y;
                    break;
                case 1:
                    q.addFirst("REPLACE " + (y + 1) + " " + t.charAt(y));
                    --x;
                    --y;
                    break;
                case 2:
                    q.addFirst("DELETE " + (y + 2));
                    --x;
                    break;
                case 3:
                    q.addFirst("INSERT " + (y + 1) + " " + t.charAt(y));
                    --y;
                    break;
            }
        }
        ArrayList<String> ans = new ArrayList<>();

        if(x == 0) {
            if(dp[0][y] == y + 1) {
                ans.add("REPLACE 1 " + t.charAt(0));
                for(int i = 2; i <= y + 1; i++) {
                    ans.add("INSERT " + i + " " + t.charAt(i - 1));
                }
            } else {
                int pos = 0;
                for(int i = 0; i <= y; i++) {
                    if(t.charAt(i) == s.charAt(0)) {
                        pos = i;
                    }
                }
                for(int i = 1; i <= pos; i++) {
                    ans.add("INSERT " + i + " " + t.charAt(i - 1));
                }
                for(int i = pos + 2; i <= y + 1; i++) {
                    ans.add("INSERT " + i + " " + t.charAt(i - 1));
                }
            }
        } else if(y == 0) {
            if(dp[x][0] == x + 1) {
                ans.add("REPLACE 1 " + t.charAt(0));
                for(int i = 2; i <= x + 1; i++) {
                    ans.add("DELETE 2");
                }
            } else {
                int pos = 0;
                for(int i = 0; i <= x; i++) {
                    if(s.charAt(i) == t.charAt(0)) {
                        pos = i;
                    }
                }
                for(int i = pos + 2; i <= x + 1; i++) {
                    ans.add("DELETE " + (pos + 2));
                }
                for(int i = 1; i <= pos; i++) {
                    ans.add("DELETE 1");
                }
            }
        }
        out.println(dp[n - 1][m - 1]);
        for(int i = 0; i < ans.size(); i++) {
            out.println(ans.get(i));
        }
        
        while(q.size() != 0) {
            out.println(q.pollFirst());
        }
    }
}

class Reader {
    private BufferedReader in;

    public Reader(InputStream in) {
        this.in = new BufferedReader(new InputStreamReader(in));
    }

    public String rl() {
        try {
            return in.readLine();
        } catch(IOException e) {
            throw new RuntimeException(e);
        }
    }

}