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.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;

public class ChangingaString2 {
	static int[][] memo;
	static String s1;
	static String s2;
	final static int INF = (int) 1e9;

	static Stack <Pair> stack=new Stack<Pair>();
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		s2 = sc.next();
		s1 = sc.next();

		memo = new int[s1.length() + 2][s2.length() + 2];
		for (int i = 0; i < s1.length() + 1; i++)
			Arrays.fill(memo[i], INF);

		memo[0][0] = 0;
		s1 = " " + s1;
		s2 = " " + s2;

		for (int i = 1; i < s1.length(); i++)
			memo[i][0] = 1 + memo[i - 1][0];

		for (int i = 1; i < s2.length(); i++)
			memo[0][i] = 1 + memo[0][i - 1];

		System.out.println(dp(s1.length() - 1, s2.length() - 1));
		dptrace(s1.length() - 1, s2.length() - 1);
		pop();
	}
	public static void pop() {
		int ctr=1;
		while(!stack.isEmpty()) {
			Pair curr=stack.pop();
			switch(curr.operation) {
			case 'r': System.out.println("REPLACE "+ ctr+ " "+curr.chr ); ctr++;
			break;
			case 'i': System.out.println("INSERT "+ ctr +" "+curr.chr ); ctr++;
			break;
			case 'd': System.out.println("DELETE "+" "+ ctr );
			break;
			case 'l': ctr++;
			break;
			}
				
		}
	}

	public static int dp(int i1, int i2) {

		if (i1 == 0 || i2 == 0)

			return memo[i1][i2];

		if (memo[i1][i2] != INF)
			return memo[i1][i2];

		if (s1.charAt(i1) == s2.charAt(i2)) {
			return memo[i1][i2] = dp(i1 - 1, i2 - 1);
		}

		else {
			return memo[i1][i2] = 1 + Math.min(dp(i1 - 1, i2 - 1), Math.min(dp(i1 - 1, i2), dp(i1, i2 - 1)));
		}
	}

	public static void dptrace(int i1, int i2) {

		if (i1 == 0 && i2 == 0)
			return;
		
		if (i1 == 0 ) {
			for(int i=1;i<=i2;i++) {
			stack.push(new Pair('d'));
			}
			return;
		}
		
		if(i2 == 0) {
			for(int i=i1;i>0;i--) {
				stack.push(new Pair('i', s1.charAt(i)));
			}
			return;
		}

		if (memo[i1][i2] == memo[i1][i2 - 1] + 1) {
			stack.push(new Pair('d'));
			dptrace(i1, i2 - 1 );

		} else if (memo[i1][i2] == memo[i1 - 1][i2] + 1) {
			stack.push(new Pair('i', s1.charAt(i1)));
			dptrace(i1 - 1, i2);

		} else if (memo[i1][i2] == memo[i1 - 1][i2 - 1]) {
			stack.push(new Pair('l'));
			dptrace(i1 - 1, i2 - 1);
//			System.out.println(s1.charAt(i1)+" like");
		} else {
			if (memo[i1][i2] == memo[i1 - 1][i2 - 1] + 1) {
				stack.push(new Pair('r', s1.charAt(i1)));
				dptrace(i1 - 1, i2 - 1);
			}
		}
	}

//	  B A D
//	G
//  O
//	O
//	D

//	 0 ACCEPTED
//   W 1
//   R  2 
//   O   3 
//   N    4
//   G      5
//   A       6
//   N       7
//   S       8
//   W       9
//   E       9
//   R        10
	
	static class Pair {
		char operation;
		char chr;
		public Pair(char o,char c) {
			operation=o;
			chr=c;
			
		}
		public Pair(char o) {
			operation=o;
		}
	}
	static class Scanner 
	{
	    StringTokenizer st;
	    BufferedReader br;

	    public Scanner(InputStream s){    br = new BufferedReader(new InputStreamReader(s));}

	    public String next() throws IOException 
	    {
	        while (st == null || !st.hasMoreTokens()) 
	            st = new StringTokenizer(br.readLine());
	        return st.nextToken();
	    }

	  
	}
}