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.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class P056D{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	String s, t;

	void run(){
		s=sc.nextLine();
		t=sc.nextLine();
		solve();
	}

	void solve(){
		int m=s.length(), n=t.length();
		int[][] dp=new int[n+1][m+1];
		int[][] op=new int[n+1][m+1];
		int insert=0, remove=1, replace0=2, replace1=3;
		for(int j=1; j<=n; j++){
			dp[j][0]=j;
			op[j][0]=insert;
		}
		for(int i=0; i<=m; i++){
			dp[0][i]=i;
			op[0][i]=remove;
		}
		for(int j=1; j<=n; j++){
			for(int i=1; i<=m; i++){
				int ins=dp[j-1][i]+1;
				int rem=dp[j][i-1]+1;
				int rep=dp[j-1][i-1]+(s.charAt(i-1)==t.charAt(j-1)?0:1);
				int min=min(ins, min(rem, rep));
				if(ins==min){
					op[j][i]=insert;
				}else if(rem==min){
					op[j][i]=remove;
				}else{
					if(rep==dp[j-1][i-1]){
						op[j][i]=replace0;
					}else{
						op[j][i]=replace1;
					}
				}
				dp[j][i]=min;
			}
		}
		LinkedList<String> list=new LinkedList<String>();
		int nRemove=0, nInsert=0;
		for(int i=m, j=n; i!=0||j!=0;){
			if(op[j][i]==insert){
				j--;
				nInsert++;
			}else if(op[j][i]==remove){
				i--;
				nRemove++;
			}else{
				i--;
				j--;
			}
		}
		for(int i=m, j=n; i!=0||j!=0;){
			if(op[j][i]==insert){
				// debug("insert", j-1, t.charAt(j-1));
				nInsert--;
				list.addFirst("INSERT "+j+" "+t.charAt(j-1));
				j--;
			}else if(op[j][i]==remove){
				// debug("remove", i-1);
				nRemove--;
				list.addFirst("DELETE "+(i-nRemove+nInsert));
				i--;
			}else if(op[j][i]==replace1){
				// debug("replace", j-1, t.charAt(j-1));
				list.addFirst("REPLACE "+j+" "+t.charAt(j-1));
				i--;
				j--;
			}else{
				i--;
				j--;
			}
		}
		println(list.size()+"");
		for(String s : list){
			println(s);
		}
	}

	void println(String s){
		System.out.println(s);
	}

	void print(String s){
		System.out.print(s);
	}

	void debug(Object... os){
		System.err.println(deepToString(os));
	}

	public static void main(String[] args){
		Locale.setDefault(Locale.US);
		new P056D().run();
	}
}