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.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.io.ObjectInputStream.GetField;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TimeZone;
import java.util.TreeMap;
import java.text.*;

public class Main {
	static int memo[][] = new int[1000][1000];
	static boolean vis[][] = new boolean[1000][1000];
	static String str1, str2;
	static StringBuilder sb = new StringBuilder();

	public static int solve(int i, int j) {

		if (i >= str1.length())
			return str2.length() - j; // insert

		if (j >= str2.length())
			return str1.length() - i; // delete

		if (vis[i][j])
			return memo[i][j];

		vis[i][j] = true;

		if (str1.charAt(i) == str2.charAt(j))
			return memo[i][j] = solve(i + 1, j + 1);

		// insert replace delete

		return memo[i][j] = 1 + Math.min(solve(i, j + 1), Math.min(solve(i + 1, j + 1), solve(i + 1, j)));
	}

	public static void buildOutput(int i, int j) {
		if (i == str1.length() && j == str2.length())
			return;
		else if (i == str1.length()) {
			sb.append("INSERT " + (j + 1) + " " + str2.charAt(j) + "\n");
			buildOutput(i, j + 1);
		} else if (j == str2.length()) {
			sb.append("DELETE " + (j + 1) + "\n");
			buildOutput(i + 1, j);
		}

		else if (str1.charAt(i) == str2.charAt(j))
			buildOutput(i + 1, j + 1);
		else if (solve(i, j) == 1 + solve(i, j + 1)) {
			sb.append("INSERT " + (j + 1) + " " + str2.charAt(j) + "\n");
			buildOutput(i, j + 1);
		} else if (solve(i, j) == 1 + solve(i + 1, j)) {
			sb.append("DELETE " + (j + 1) + "\n");
			buildOutput(i + 1, j);
		} else if (solve(i, j) == 1 + solve(i + 1, j + 1)) {
			sb.append("REPLACE " + (j + 1) + " " + str2.charAt(j) + "\n");
			buildOutput(i + 1, j + 1);
		}

	}

	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		str1 = in.next();
		str2 = in.next();
		out.println(solve(0, 0));
		buildOutput(0, 0);
		out.println(sb);
		out.close();
	}

}

class FastReader {
	BufferedReader br;
	StringTokenizer st;

	public FastReader() {
		br = new BufferedReader(new InputStreamReader(System.in));

	}

	public FastReader(File f) throws FileNotFoundException {
		br = new BufferedReader(new FileReader(f));
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());

			} catch (IOException e) {
				e.printStackTrace();
			}

		}

		return st.nextToken();

	}

	int nextInt() {

		return Integer.parseInt(next());
	}

	double nextDouble() {

		return Double.parseDouble(next());
	}

	long nextLong() {

		return Long.parseLong(next());
	}

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();

		} catch (IOException e) {

			e.printStackTrace();
		}
		return str;

	}

	boolean ready() throws IOException {
		return br.ready();
	}
}