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.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream.GetField;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.text.CollationKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	static class Edge implements Comparable<Edge> {
		int node;
		double cost;

		public Edge(int s, double cost) {
			node = s;
			this.cost = cost;
		}

		@Override
		public int compareTo(Edge e) {
			if (Math.abs(cost - e.cost) < 1e-9)
				return 0;
			return (int) (cost - e.cost);
		}

	}

	static int dijkstra(int S, double[] dist) // O(E log E)
	{
		// int[] dist = new int[V];
		Arrays.fill(dist, INF);
		PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
		dist[S] = 0;
		pq.add(new Edge(S, 0)); // may add more in case of MSSP (Mult-Source)
		while (!pq.isEmpty()) {
			Edge cur = pq.remove();
			// if(cur.node == T) //remove if all computations are needed
			// return dist[T];
			if (cur.cost > dist[cur.node]) // lazy deletion
				continue;
			for (Edge nxt : adjList[cur.node])
				if (cur.cost + nxt.cost < dist[nxt.node])
					pq.add(new Edge(nxt.node, dist[nxt.node] = cur.cost + nxt.cost));
		}
		return -1;
	}

	static ArrayList<Edge>[] adjList;
	static int p, realp = 0;
	static int[] arr;
	static double[] Arr;
	static int[][] memo;
	static int INF = Integer.MAX_VALUE;
	static HashMap<Integer, Integer> prev;
	static HashMap<Integer, Long> cost;

	public static int dp(int s, int t) {
		if (s == Str1.length())
			return  Str2.length()-t;
		if (t == Str2.length())
			return  Str1.length()-s;
		if (Str1.charAt(s) == Str2.charAt(t))
			return dp(s +1, t +1);
		if (memo[s][t] != -1)
			return memo[s][t];
		int add = 1 + dp(s, t + 1);
		int remove = 1 + dp(s + 1, t);
		int replace = 1 + dp(s + 1,t + 1 );
		return memo[s][t] = Math.min(Math.min(add, remove), replace);

	}

	static Queue<String> q;

	public static void trace(int s,int t,int c) {
		if (s == Str1.length()) {
			for (int i = t; i < Str2.length(); i++)
				q.add("INSERT" + " " + (c++) + " " + Str2.charAt(i));
			return;
		}
		if (t == Str2.length()) {
			for (int i = s; i < Str1.length(); i++)
				q.add("DELETE " + " " + (c) );
			return;
		}

		if (Str1.charAt(s) == Str2.charAt(t))
			trace(s +1, t +1,c+1);
		else {
			if (dp(s, t) == 1 + dp(s, t + 1)) {
				q.add("INSERT" + " " + (c) + " " + Str2.charAt(t));
				trace(s,  t +1,c+1);
			} else if (dp(s, t) == 1 + dp(s + 1,  t)) {
				q.add("DELETE " + " " + (c) );
				trace(s + 1, t,c);
			} else {
				q.add("REPLACE" + " " + (c) + " " + Str2.charAt(t));
				trace(s + 1, t + 1,c+1);
			}
		}

	}

	static PrintWriter pw;
	static double[][] matrix;
	static String Str1, Str2;

	public static void main(String[] args) throws IOException, InterruptedException {
		// FileWriter f = new FileWriter("C:\\Users\\Hp\\Desktop\\out.txt");
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		Scanner sc = new Scanner(System.in);
		// Thread.sleep(3000);
		Str1 = sc.next();
		Str2 = sc.next();
		memo = new int[Str1.length() + 1][Str2.length() + 1];
		for (int i = 0; i < Str1.length() + 1; i++)
			Arrays.fill(memo[i], -1);
		pw.println(dp(0, 0));
		q = new LinkedList<String>();
		trace(0,0,1);
		while (!q.isEmpty())
			pw.println(q.poll());
		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

		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 {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

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

	}

}