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


public class Main {

	static PrintWriter pw = new PrintWriter(System.out);
	static int n,m;
	static  final int INF=(int)1e9;
	static String A,B;
	static StringBuilder sb ;
	static int[][] memo;
	public static void main(String[] args) throws  IOException, InterruptedException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st ;
		sb=new StringBuilder();

		A=bf.readLine();
		B=bf.readLine();
		memo= new int[1001][1001];
		for(int i=0;i<memo.length;i++)Arrays.fill(memo[i],-1);
	
		pw.println(dpSol(0,0));
		print(0,0);
		pw.flush();
		pw.close();

	}

public static int dpSol(int idxA,int idxB) {

	if(idxA==A.length()&&idxB==B.length())return 0;
	if(idxA==A.length()) 
		return memo[idxA][idxB]=B.length()-idxB;
	if(idxB==B.length()) 
		return memo[idxA][idxB]=A.length()-idxA;

	if(memo[idxA][idxB]!=-1)return memo[idxA][idxB];
	if(A.charAt(idxA)==B.charAt(idxB))return memo[idxA][idxB]=dpSol(idxA+1,idxB+1);
	return memo[idxA][idxB]=1+Math.min(dpSol(idxA+1,idxB+1),Math.min(dpSol(idxA,idxB+1),dpSol(idxA+1,idxB)));
	
}
public static void print(int idxA,int idxB) {
	if(idxA==A.length()&&idxB==B.length())return;
	if(idxA==A.length()) {
		while(idxB++<B.length())pw.println("INSERT "+(idxB)+" "+B.charAt(idxB-1));
return;	
	}
	else if(idxB==B.length()) {
	while(idxA++<A.length())pw.println("DELETE "+(idxB+1));
return;
	}	
	else if(A.charAt(idxA)==B.charAt(idxB)) {
	print(idxA+1,idxB+1);
return;
}
int ans= memo[idxA][idxB];
	
if(ans-1==dpSol(idxA+1,idxB+1)) {
	pw.println("REPLACE "+(idxB+1)+" "+B.charAt(idxB));
	print(idxA+1,idxB+1);
}
else if(ans-1==dpSol(idxA,idxB+1)) {
	pw.println("INSERT "+(idxB+1)+" "+B.charAt(idxB));
	print(idxA,idxB+1);
}

else if(ans-1==dpSol(idxA+1,idxB)) {
	pw.println("DELETE "+(idxB+1));
	print(idxA+1,idxB);
}
	
}
	static public class UDS {
		int[] parent,rank,setSize;
		int n;//number of sets

		public UDS(int n) {

			this.n=n;
			parent=new int[n];
			rank=new int[n];
			setSize=new int[n];
			Arrays.fill(setSize, 1);
			for(int i=0;i<n;i++)parent[i]=i;
		}

		public  boolean unionSet(int i, int j) {
			if(!isSameSet(i, j)) {
				n--;
				int p1=findSet(i);
				int p2=findSet(j);
				if(rank[p1]<rank[p2]) {
					parent[p1]=p2;
					setSize[p2]+=setSize[p1];
				}else {
					parent[p2]=p1;
					setSize[p1]+=setSize[p2];
					if(rank[p1]==rank[p2])rank[p1]++;
				}
				return true;	
			}
			return false;
		}

		public int sizeOfSet(int i) {return setSize[findSet(i)];}

		public int numDisjointSets() {return n;}

		public boolean isSameSet(int i,int j) {
			return findSet(i)==findSet(j);
		}

		public int findSet(int i) {
			return (parent[i]==i)? i : (parent[i]=findSet(parent[i]));
		}
	}
	static class Edge implements Comparable<Edge>{
		int u ,  v; int cost;
		public Edge(int u , int v, int w) {
			this.u=u;this.v=v;cost=w;
		}

		public int compareTo(Edge e) {
			return (this.cost)-(e.cost);
		}
	}


}