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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int tab[2000][2000] = {};
void walkthru(int won, int too, char* s, char* t) {
  if (!won) {
    if (!too) {
      return;
    }
  }
  int g = tab[won][too];
  int g2 = tab[won - 1][too] + 1;
  bool c = false;
  bool d = false;
  if (g == g2) c = true;
  g2 = tab[won][too - 1] + 1;
  if (g == g2) d = true;
  char tl = t[too];
  int t1 = won - 1;
  int t2 = too - 1;
  if (!(t1 < 0)) {
  } else
    c = false;
  if (!(t2 < 0)) {
  } else
    d = false;
  if (c) {
    walkthru(t1, too, s, t);
    cout << "DELETE "
         << " " << too + 1 << endl;
  } else if (d) {
    walkthru(won, t2, s, t);
    cout << "INSERT " << too << " " << tl << endl;
  } else if (s[won] == t[too] && !c && !d) {
    walkthru(t1, too - 1, s, t);
  } else {
    walkthru(won - 1, t2, s, t);
    cout << "REPLACE " << too << " " << tl << endl;
  }
}
int main() {
  char r[2000];
  char z[2000];
  scanf("%s%s", r + 1, z + 1);
  for (int j = 0; j < strlen(z + 1) + 1; j++) {
    if (j == 0)
      continue;
    else {
      tab[0][j] = j;
    }
  }
  for (int i = 0; i < strlen(r + 1) + 1; i++) {
    if (i == 0)
      continue;
    else {
      tab[i][0] = i;
    }
  }
  for (int k = 0; k < strlen(r + 1) + 1; k++) {
    if (k == 0) continue;
    for (int l = 0; l < strlen(z + 1) + 1; l++) {
      if (l == 0) continue;
      if (tab[k - 1][l] > tab[k][l - 1]) {
        tab[k][l] = tab[k][l - 1];
      } else {
        tab[k][l] = tab[k - 1][l];
      }
      tab[k][l]++;
      int adder = 1;
      if (r[k] == z[l]) adder = 0;
      int temp5 = tab[k - 1][l - 1] + adder;
      if (tab[k][l] > temp5) {
        tab[k][l] = temp5;
      } else {
        tab[k][l] = tab[k][l];
      }
    }
  }
  cout << tab[strlen(r + 1)][strlen(z + 1)] << endl;
  walkthru(strlen(r + 1), strlen(z + 1), r, z);
}