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.*;

public class D {
	int[][] c, op;
	String a, b;
	int mod = 0;
	
	void print(int i, int j){
		if(i<0 && j<0) return;
		
		if(i<0){
			print(i,j-1);
			System.out.println("INSERT " + (j+1) + " " + b.charAt(j));			
			return;
		} else if(j<0){
			print(i-1,j);
			System.out.println("DELETE 1");			
			return;
		}
		
		if(a.charAt(i)==b.charAt(j)){
			print(i-1,j-1);
			return;
		}
		
		switch(op[i+1][j+1]){
		case 0:
			print(i,j-1);
			System.out.println("INSERT " + (j+1) + " " + b.charAt(j));
			break;
		case 1:
			print(i-1,j-1);
			System.out.println("REPLACE " + (j+1) + " " + b.charAt(j));
			break;
		case 2:
			print(i-1,j);
			System.out.println("DELETE " + (j+2));
			break;
		}
		
	}
	
	void run()throws IOException{
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		a = bf.readLine();
		b = bf.readLine();
		EditDistance ed = new EditDistance(a, b);
		System.out.println(ed.run());
		c = ed.cost;
		op = ed.operations;

		print(a.length()-1, b.length()-1);
	}
	
	public static void main(String[] args)throws IOException {
		new D().run();
	}

	/**
	 * EditDistance problem O(n*m)
	 * Input: String src and String dest
	 * The first constructor initializes the cost of each operation to one, so the return value is the min. number of 
	 *    operations to transfrom the string src to the string dest
	 *  The second constructor takes an int array with the cost of each operation (insert, copy, delete), so, the return value is
	 *    the min. cost to transfrom the string src to the string dest
	 */
	private class EditDistance {
		String src, dest;
		int[][] cost;
		int[][] operations;
		int[] opCost;
		final int INSERT = 0;
		final int COPY = 1;
		final int DELETE = 2;
		
		public EditDistance(String src, String dest){
			this.src = src;
			this.dest = dest;
			operations = new int[src.length()+1][dest.length()+1];
			cost = new int[src.length()+1][dest.length()+1];
			opCost = new int[3];
			opCost[0]=opCost[1]=opCost[2]=1; //operations cost = 1 to obtain the min. number of operations to trasform source to dist
		}
				
		void init(){
			int i;
			cost[0][0]=0;
			for(i=1;i<=src.length();i++) cost[i][0] = opCost[DELETE]+cost[i-1][0];
			for(i=1;i<=dest.length();i++) cost[0][i] = opCost[INSERT]+cost[0][i-1];
		}
		
		int getMinOperation(int ins, int cpy, int del){
			if(ins<cpy){
				if(ins<del) return INSERT;
				else return DELETE;
			} else{
				if(cpy<del) return COPY;
				else return DELETE;
			}
		}
		
		int run(){
			init();
			int i,j,ins,cpy,del;
			int srcLen=src.length(), destLen=dest.length();
			
			for(i=1;i<=srcLen;i++){
				for(j=1;j<=destLen;j++){
					ins = opCost[INSERT] + cost[i][j-1];
					del = opCost[DELETE] + cost[i-1][j];
					if(src.charAt(i-1)==dest.charAt(j-1)) cpy = cost[i-1][j-1];
					else cpy = opCost[COPY] + cost[i-1][j-1];
					
					operations[i][j] = getMinOperation(ins,cpy,del);
					
					switch(operations[i][j]){
					case INSERT:
						cost[i][j] = ins;
						break;
					case COPY:
						cost[i][j] = cpy;
						break;
					case DELETE:
						cost[i][j] = del;
						break;
					}
				}
			}
			
			return cost[src.length()][dest.length()];
		}
	}
}