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;
inline void read(int &x) {
  register int c = getchar();
  x = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
inline void write(int x) {
  char buffor[12];
  register int i = 0;
  int neg = 0;
  if (x < 0) {
    neg = 1;
    x = -x;
  }
  do {
    buffor[i++] = (x % 10) + '0';
    x /= 10;
  } while (x);
  i--;
  if (neg) putchar('-');
  while (i >= 0) putchar(buffor[i--]);
}
inline void writeln(int x) {
  write(x);
  putchar('\n');
}
inline void read(long long &x) {
  register int c = getchar();
  x = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
inline void write(long long x) {
  char buffor[21];
  register int i = 0;
  int neg = 0;
  if (x < 0) {
    neg = 1;
    x = -x;
  }
  do {
    buffor[i++] = (x % 10) + '0';
    x /= 10;
  } while (x);
  i--;
  if (neg) putchar('-');
  while (i >= 0) putchar(buffor[i--]);
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
const int N = 1005, INF = N;
string s, t;
int n, m;
void enter() {
  cin >> s >> t;
  n = ((int)(s).size());
  m = ((int)(t).size());
  s = ' ' + s + ' ';
  t = ' ' + t + ' ';
}
int dp[N][N];
inline void mini(int &x, int y) {
  if (x > y) x = y;
}
int trace(int x, int y) {
  if (x == 0 && y == 0) return 0;
  if (x && dp[x][y] == dp[x - 1][y] + 1) {
    int p = trace(x - 1, y);
    cout << "DELETE " << p + 1 << '\n';
    return p;
  } else if (y && dp[x][y] == dp[x][y - 1] + 1) {
    int p = trace(x, y - 1);
    cout << "INSERT " << p + 1 << " " << t[y] << '\n';
    return p + 1;
  } else if (x && y && dp[x][y] == dp[x - 1][y - 1]) {
    return trace(x - 1, y - 1) + 1;
  } else if (x && y && dp[x][y] == dp[x - 1][y - 1] + 1) {
    int p = trace(x - 1, y - 1);
    cout << "REPLACE " << p + 1 << " " << t[y] << '\n';
    return p + 1;
  }
}
void process() {
  for (int i = (0), _b = (n + 1); i <= _b; ++i)
    for (int j = (0), _b = (m + 1); j <= _b; ++j) dp[i][j] = INF;
  for (int i = (0), _b = (n); i <= _b; ++i) dp[i][0] = i;
  for (int j = (0), _b = (m); j <= _b; ++j) dp[0][j] = j;
  for (int i = (1), _b = (n); i <= _b; ++i)
    for (int j = (1), _b = (m); j <= _b; ++j) {
      mini(dp[i][j], min(dp[i - 1][j], dp[i][j - 1]) + 1);
      mini(dp[i][j], dp[i - 1][j - 1] + (s[i] != t[j]));
    }
  cout << dp[n][m] << '\n';
  trace(n, m);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  enter();
  process();
  return 0;
}