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 static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					try {
						if (new File("input.txt").exists())
							System.setIn(new FileInputStream("input.txt"));
					} catch (SecurityException e) {}
					new Main().run();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start(); 
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");
	
	char[] s1;
	char[] s2;
	int len1;
	int len2;
	int[][] mem;
	
	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		
		s1 = nextToken().toCharArray(); len1 = s1.length;
		s2 = nextToken().toCharArray(); len2 = s2.length;
		mem = new int [len1 + 1][len2 + 1];
		for (int[] a : mem)
			fill(a, -1);
		out.println(rec(0, 0));
		print(0, 0);
		
		out.close();
	}
	
	int rec(int pos1, int pos2) {
		if (pos1 == len1 && pos2 == len2)
			return 0;
		if (pos1 == len1) {
			return rec(pos1, pos2 + 1) + 1;
		} else if (pos2 == len2) {
			return rec(pos1 + 1, pos2) + 1;
		} else {
			if (mem[pos1][pos2] != -1)
				return mem[pos1][pos2];
			int ret = Integer.MAX_VALUE / 5;
			if (s1[pos1] == s2[pos2])
				ret = min(ret, rec(pos1 + 1, pos2 + 1));
			ret = min(ret, rec(pos1, pos2 + 1) + 1);     // Insert
			ret = min(ret, rec(pos1 + 1, pos2) + 1);     // Delete
			ret = min(ret, rec(pos1 + 1, pos2 + 1) + 1); // Replace
			return mem[pos1][pos2] = ret;
		}
	}
	
	void print(int pos1, int pos2) {
		if (pos1 == len1 && pos2 == len2)
			return;
		if (pos1 == len1) {
			out.println("INSERT " + (pos2 + 1) + " " + s2[pos2]);
			print(pos1, pos2 + 1);
		} else if (pos2 == len2) {
			out.println("DELETE " + (pos2 + 1));
			print(pos1 + 1, pos2);
		} else {
			int val = rec(pos1, pos2);
			if (s1[pos1] == s2[pos2]) {
				if (val == rec(pos1 + 1, pos2 + 1)) {
					print(pos1 + 1, pos2 + 1);
					return;
				}
			}
			if (val == rec(pos1, pos2 + 1) + 1) {
				out.println("INSERT " + (pos2 + 1) + " " + s2[pos2]);
				print(pos1, pos2 + 1);
				return;
			}
			if (val == rec(pos1 + 1, pos2) + 1) {
				out.println("DELETE " + (pos2 + 1));
				print(pos1 + 1, pos2);
				return;
			}
			if (val == rec(pos1 + 1, pos2 + 1) + 1) {
				out.println("REPLACE " + (pos2 + 1) + " " + s2[pos2]);
				print(pos1 + 1, pos2 + 1);
				return;
			}
			throw new RuntimeException("Error!!!");
		}
	}

	String nextToken() throws IOException {
		while (!st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		
		return st.nextToken();
	}
	
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			
			if (s == null) {
				return true;
			}
			
			st = new StringTokenizer(s);
		}
		
		return false;
	}
}