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 Scanner scanner = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    static final long INF = (long)1e18;
    static int[][] memo;
    static String s,t;
    static StringBuilder sb;
    public static void main(String[] args) throws Exception {
        //============================================//
        //answer here:
        //similar to longest common subsequence problem:
        s=scanner.nextLine(); t=scanner.nextLine();
        memo=new int[s.length()][t.length()];
        for (int[] arr:memo) Arrays.fill(arr,-1);
        sb=new StringBuilder();
        int res=dp(0,0);
        out.println(res);
        trace(0,0);
        out.println(sb);
        //============================================//
        out.close();
    }
    public static int gcd(int a, int b){
        return (a==0)?b:gcd(b%a,a);
    }
    public static int dp(int is,int it){
        if (is>=s.length()) return t.length()-it;
        if (it>=t.length()) return s.length()-is;
        if (memo[is][it]!=-1)return memo[is][it];
        int min;
        if (s.charAt(is)==t.charAt(it))
            min=dp(is+1,it+1);
        else
            min=Math.min(dp(is+1,it),Math.min(dp(is,it+1),dp(is+1,it+1)))+1;
        return memo[is][it]=min;
    }
    public static void trace(int is, int it){
        if (is>=s.length()) {
            while (it < t.length()) {
                sb.append("INSERT " + (it + 1) + " " + t.charAt(it)+'\n');
                ++it;
            }
            return;
        }
        if (it>=t.length()){
            while (is<s.length()){
                sb.append("DELETE "+(it+1)+'\n');
                ++is;
            }
            return;
        }
        int ans=dp(is,it)-1;
        if (s.charAt(is)==t.charAt(it)) trace(is+1,it+1);
        else if (dp(is+1,it+1)==ans){
            sb.append("REPLACE "+(it+1)+" "+t.charAt(it)+'\n');
            trace(is+1,it+1);
        }
        else if (dp(is+1,it)==ans){
            sb.append("DELETE "+(it+1)+'\n');
            trace(is+1,it);
        }else if (dp(is,it+1)==ans){
            sb.append("INSERT " + (it + 1) + " " + t.charAt(it)+'\n');
            trace(is,it+1);
        }

    }
}


class Scanner {
    StringTokenizer st;
    BufferedReader br;

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

    public Scanner(String file) throws Exception {
        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 String nextLine() throws IOException {
        return br.readLine();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public char nextChar() throws IOException {
        return next().charAt(0);
    }

    public Long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public boolean ready() throws IOException {
        return br.ready();
    }

    public void waitForInput() throws InterruptedException {
        Thread.sleep(3000);
    }

    int[] readArray(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    long[] readLongArray(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

class pair implements Comparable<pair> {
    int t;
    int c;

    public pair(int t, int c) {
        this.t= t;
        this.c= c;
    }

    @Override
    public String toString() {
        return t+""+c;
    }

    @Override
    public int compareTo(pair o) {
        return o.t-t;
    }
}