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.*;
 
import java.util.*;
 
 
 
public class Main {
 
static PrintWriter pw = new PrintWriter(System.out);
 
	public static void main(String[] args) throws Exception {
 
		Scanner sc = new Scanner(System.in);
 
		
 
		sp=new StringBuilder(sc.nextLine());
		sp1=new StringBuilder(sc.nextLine());
		n=sp.length();
		n1=sp1.length();
		dp=new int[sp.length()+2][sp1.length()+2];
		for(int[] i:dp)Arrays.fill(i,-1);
		for(int i=100;i<n;i+=100){
		    for(int j=100;j<n1;j+=100){
		        solve(i,j);
		    }
		}
        pw.println(solve(0,0));
        trace(0,0);
		pw.close();
 
	}static StringBuilder sp,sp1;
	static int[][]dp;
	static int n;
	static int n1;
	public static int solve(int i,int j){
	    if(i==n||j==n1){
	        return (n1+n-j-i);
	    }
	    if(dp[i][j]!=-1)return dp[i][j];
	    if(sp.charAt(i)==sp1.charAt(j))return dp[i][j]=solve(i+1,j+1);
	    return(dp[i][j]=Math.min(solve(i+1,j),Math.min(solve(i,j+1),solve(i+1,j+1)))+1);
	}
	public static void trace(int i,int j){
	    if(i==n){
	        while(j++<n1){
	            pw.println("INSERT "+(j)+" "+sp1.charAt(j-1));
	        }return;
	    }
	    if(j==n1){
	        while(i++<n){
	            pw.println("DELETE "+(j+1));
	        }return ;
	    }
	    if(sp.charAt(i)!=sp1.charAt(j)){
	    int temp=solve(i,j);
	    if(temp==solve(i+1,j)+1){
	        pw.println("DELETE "+(1+j));
	        trace(i+1,j);
	        return ;
	    }
	    if(temp==solve(i,j+1)+1){
	        pw.println("INSERT "+(1+j)+" "+sp1.charAt(j));
	        trace(i,j+1);
	        return ;
	    }
	    if(temp==solve(i+1,j+1)+1){
	        pw.println("REPLACE "+(j+1)+" "+sp1.charAt(j));
	        trace(i+1,j+1);
	        return ;
	    }}
	    else {
	    trace(i+1,j+1);return;}
	}
public static boolean prime(int x){
	    int[] arr=new int[10000000];
	    int index=0;
	    int num=3;
	    int i=0;
	    arr[0]=2;
	    while(num<=x){
	      for(i=0;i<=index;i++){
	          if(num%arr[i]==0){
	              break;
	          }
	      }
	      if(i==index+1){
	          arr[++index]=num;
	      }
	      num++;
	    }
	    if(arr[index]==x)return true;
	    return false;
	      
	}
public static void conquer(int[] arr,int b,int m,int e){
	    int len1=m-b+1;
	    int len2=e-m;
	    int[] l=new int[len1];
	    int[] r=new int[len2];
	    for(int i=0;i<len1;i++){
	        l[i]=arr[b+i];
	    }
	   for(int j=0;j<len2;j++){
	            r[j]=arr[m+1+j];
	   }
	    int i=0,j=0,k=b;
	    while((i<len1)&&(j<len2)){
	        if(r[j]>=l[i]){
	            arr[k]=l[i];
	            k++;
	            i++;
	        }
	        else{
	           arr[k]=r[j];
	           k++;
	           j++;
	        }
	    }
	    while(i<len1){
	        arr[k++]=l[i++];
	    }
	    while(j<len2){
	        arr[k++]=r[j++];
	    }
	}
	static int mid;
	public static void sort(int[] arr,int b,int e){
	    if(b<e){
	        int mid =(e+b)/2;
	        sort(arr,b,mid);
	        sort(arr,mid+1,e);
	        conquer(arr,b,mid,e);
	    }
	}
    public static void Sort(int[] arr){
        sort(arr,0,arr.length-1);
    }
 
	static class Scanner {
 
		StringTokenizer st;
 
		BufferedReader br;
 
 
 
		public Scanner(InputStream s) {
 
			br = new BufferedReader(new InputStreamReader(s));
 
		}
 
 
 
		public Scanner(String file) throws FileNotFoundException {
 
			br = new BufferedReader(new FileReader(file));
 
		}
 
 
 
		public String next() throws IOException {
 
			while (st == null || !st.hasMoreTokens())
 
				st = new StringTokenizer(br.readLine());
 
			return st.nextToken();
 
		}
 
 
 
		public int nextInt() throws IOException {
 
			return Integer.parseInt(next());
 
		}
 
 
 
		public long nextLong() throws IOException {
 
			return Long.parseLong(next());
 
		}
 
 
 
		public String nextLine() throws IOException {
 
			return br.readLine();
 
		}
 
 
 
		public double nextDouble() throws IOException {
 
			return Double.parseDouble(next());
 
		}
 
 
 
		public boolean ready() throws IOException {
 
			return br.ready();
 
		}
 
 
 
	}
 
}