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

public class Main {

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

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");
	int min (int a, int b){
		return (a>b)? b : a;
	}
	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		String T = nextLine();
		String P = nextLine();
		int lp = P.length();
		int lt = T.length();
		int din[][] = new int[lp + 1][lt + 1];
		int pp[][] = new int[lp + 1][lt + 1];
		int pt[][] = new int[lp + 1][lt + 1];
		int z = lp+lt+1;
		for(int i = 0; i < lp + 1;i++){
			Arrays.fill(din[i], z);
		}
		din[0][0] = pp[0][0] = pt[0][0] = 0;
		for(int i = 0; i <= lp; i++)//< ?
			for(int j = 0; j <= lt; j++){
				if(i + 1 <= lp){	// INSERT
					if(din[i+1][j] > din[i][j] + 1){
						din[i+1][j] = din[i][j] + 1;
						pp[i+1][j] = i;
						pt[i+1][j] = j;
					}
				}
				if(j + 1 <= lt){	//DELETE
					if(din[i][j+1] > din[i][j] + 1){
						din[i][j  + 1] = din[i][j] + 1;
						pp[i][j + 1] = i;
						pt[i][j + 1] = j;
					}
				}
				if(i+1 <= lp && j+1<=lt && T.charAt(j) == P.charAt(i)){	//save
					if(din[i+1][j+1] > din[i][j]){
						din[i+1][j+1] = din[i][j];
						pp[i+1][j+1] = i;
						pt[i+1][j+1] = j;
					}
				}
				if(i+1 <= lp && j+1<=lt){	//REPLACE
					if(din[i+1][j+1] > din[i][j] + 1){
						din[i+1][j+1] = din[i][j] + 1;
						pp[i+1][j+1] = i;
						pt[i+1][j+1] = j;
					}
				}
		}
		int rez = din[lp][lt];
		out.println(rez);
		int sp[] = new int[z];
		int st[] = new int[z];
		int ip = lp;
		int it = lt;
		int p = 0;
		do{
			sp[p] = ip;
			st[p++]= it;
			int a = pp[ip][it];
			it = pt[ip][it];
			ip = a;
		}while( (ip | it) != 0);
		int delta = 0;
		ip = it = 0;
		while(p-- != 0){
			if(ip + 1 == sp[p] && it + 1 == st[p]){//save / REPLACE
				if(din[ip][it] == din[sp[p]][st[p]])
					;//out.println("save");
				else 
					out.println("REPLACE " + (st[p] + delta) + " " + P.charAt(ip));
			}
			if(ip + 1 == sp[p] && it == st[p]){//INSERT
				delta++;
				out.println("INSERT " + (st[p] + delta) + " " + P.charAt(ip));
				
			}
			if(ip == sp[p] && it + 1 == st[p]){//DELETE
				out.println("DELETE " + (st[p] + delta));
				delta--;
			}
			ip = sp[p];
			it = st[p];
		}
		in.close();
		out.close();
	}

	void chk(boolean b) {
		if (b)
			return;
		System.out.println(new Error().getStackTrace()[1]);
		exit(999);
	}
	void deb(String fmt, Object... args) {
		System.out.printf(Locale.US, fmt + "%n", args);
	}
	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;
	}
}