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>
int diru[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dirv[] = {-1, 0, 1, -1, 1, -1, 0, 1};
using namespace std;
template <class T>
T sq(T n) {
  return n * n;
}
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
bool inside(T a, T b, T c) {
  return a <= b && b <= c;
}
template <class T>
void setmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void setmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
T power(T N, T P) {
  return (P == 0) ? 1 : N * power(N, P - 1);
}
int dp[1010][1010];
int p[1010][1010][3];
char s[1010];
char t[1010];
int cal(int i, int j) {
  if (i < 0 && j < 0) return 0;
  if (i < 0) return j + 1;
  if (j < 0) return i + 1;
  if (dp[i][j] != -1) return dp[i][j];
  int cost, ret, tmp;
  if (s[i] == t[j])
    cost = 0;
  else
    cost = 1;
  ret = 1 + cal(i, j - 1);
  p[i][j][0] = 0;
  p[i][j][1] = j + 1;
  p[i][j][2] = t[j];
  tmp = 1 + cal(i - 1, j);
  if (ret > tmp) {
    ret = tmp;
    p[i][j][0] = 1;
    p[i][j][1] = j + 2;
    p[i][j][2] = s[i];
  }
  tmp = cal(i - 1, j - 1) + cost;
  if (ret > tmp) {
    ret = tmp;
    p[i][j][0] = 2;
    p[i][j][1] = j + 1;
    if (cost)
      p[i][j][2] = t[j];
    else
      p[i][j][2] = 0;
  }
  return dp[i][j] = ret;
}
void print(int i, int j) {
  if (i < 0 && j < 0) return;
  int k;
  if (i < 0) {
    for (k = 0; k < j + 1; k++) printf("INSERT %d %c\n", k + 1, t[k]);
    return;
  }
  if (j < 0) {
    for (k = i; k > -1; k--) printf("DELETE 1\n");
    return;
  }
  if (p[i][j][0] == 0) {
    print(i, j - 1);
    printf("INSERT %d %c\n", p[i][j][1], p[i][j][2]);
  } else if (p[i][j][0] == 1) {
    print(i - 1, j);
    printf("DELETE %d\n", p[i][j][1]);
  } else {
    print(i - 1, j - 1);
    if (p[i][j][2]) printf("REPLACE %d %c\n", p[i][j][1], p[i][j][2]);
  }
}
int main() {
  int i, j;
  while (scanf("%s%s", s, t) == 2) {
    int ls = strlen(s);
    int lt = strlen(t);
    for (i = 0; i < ls; i++)
      for (j = 0; j < lt; j++) dp[i][j] = -1;
    printf("%d\n", cal(ls - 1, lt - 1));
    print(ls - 1, lt - 1);
  }
  return 0;
}