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

public class D implements Runnable {

	final int INF = Integer.MAX_VALUE / 2;

	void solve() {
		char[] s1 = nextToken().toCharArray();
		char[] s2 = nextToken().toCharArray();
		int[][] dp = new int[s1.length + 1][s2.length + 1];
		int[][] p = new int[s1.length + 1][s2.length + 1];
		for (int i = 0; i < dp.length; i++) {
			Arrays.fill(dp[i], INF);
		}
		dp[0][0] = 0;
		for (int i = 0; i <= s1.length; i++) {
			for (int j = 0; j <= s2.length; j++) {
				if (i == 0 && j == 0) {
					continue;
				}
				if (i > 0) {
					if (dp[i][j] > dp[i - 1][j] + 1) {
						dp[i][j] = dp[i - 1][j] + 1;
						p[i][j] = 1;
					}
				}
				if (j > 0) {
					if (dp[i][j] > dp[i][j - 1] + 1) {
						dp[i][j] = dp[i][j - 1] + 1;
						p[i][j] = 2;
					}
				}
				if (i > 0 && j > 0) {
					if (s1[i - 1] == s2[j - 1]) {
						if (dp[i][j] > dp[i - 1][j - 1]) {
							dp[i][j] = dp[i - 1][j - 1];
							p[i][j] = 0;
						}
					} else {
						if (dp[i][j] > dp[i - 1][j - 1] + 1) {
							dp[i][j] = dp[i - 1][j - 1] + 1;
							p[i][j] = 3;
						}
					}
				}
			}
		}
		ArrayList<String> ans = new ArrayList<String>();
		for (int i = s1.length, j = s2.length; i > 0 || j > 0;) {
			int got = p[i][j];
			if (got == 0) {
				i--;
				j--;
			} else if (got == 3) {
				ans.add("REPLACE " + i + " " + s2[j - 1]);
				i--;
				j--;
			} else if (got == 1) {
				ans.add("DELETE " + i);
				i--;
			} else {
				ans.add("INSERT " + (i + 1) + " " + s2[j - 1]);
				j--;
			}
		}
		out.println(ans.size());
		for (String s : ans) {
			out.println(s);
		}
	}

	FastScanner sc;
	PrintWriter out;

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			sc = new FastScanner(System.in);
			out = new PrintWriter(System.out);
			solve();
			sc.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	int nextInt() {
		return sc.nextInt();
	}

	String nextToken() {
		return sc.nextToken();
	}

	long nextLong() {
		return sc.nextLong();
	}

	double nextDouble() {
		return sc.nextDouble();
	}

	BigInteger nextBigInteger() {
		return sc.nextBigInteger();
	}

	class FastScanner extends BufferedReader {
		StringTokenizer st;
		boolean eof;
		String buf;
		String curLine;
		boolean createST;

		public FastScanner(String fileName) throws FileNotFoundException {
			this(fileName, true);
		}

		public FastScanner(String fileName, boolean createST)
				throws FileNotFoundException {
			super(new FileReader(fileName));
			this.createST = createST;
			nextToken();
		}

		public FastScanner(InputStream stream) {
			this(stream, true);
		}

		public FastScanner(InputStream stream, boolean createST) {
			super(new InputStreamReader(stream));
			this.createST = createST;
			nextToken();
		}

		String nextLine() {
			String ret = curLine;
			if (createST) {
				st = null;
			}
			nextToken();
			return ret;
		}

		String nextToken() {
			if (!createST) {
				try {
					curLine = readLine();
				} catch (Exception e) {
					eof = true;
				}
				return null;
			}
			while (st == null || !st.hasMoreTokens()) {
				try {
					curLine = readLine();
					st = new StringTokenizer(curLine);
				} catch (Exception e) {
					eof = true;
					break;
				}
			}
			String ret = buf;
			buf = eof ? "-1" : st.nextToken();
			return ret;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}

		BigInteger nextBigInteger() {
			return new BigInteger(nextToken());
		}

		public void close() {
			try {
				buf = null;
				st = null;
				curLine = null;
				super.close();
			} catch (Exception e) {

			}
		}

		boolean isEOF() {
			return eof;
		}
	}

	public static void main(String[] args) {
		new D().run();
	}
}