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;
clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
template <typename T>
void _F(const char *name, T arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename T, typename... Args>
void _F(const char *names, T arg1, Args... args) {
  const char *name = strchr(names, ',');
  cerr.write(names, name - names) << " = " << arg1 << '\n';
  _F(name + 2, args...);
}
template <typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &q) {
  in >> q.first >> q.second;
  return in;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &out, pair<T1, T2> &q) {
  out << q.first << " " << q.second;
  return out;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2) {
  return {p1.first + p2.first, p1.second + p2.second};
}
template <typename T1, typename T2>
pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2) {
  return {p1.first - p2.first, p1.second - p2.second};
}
const long long N = 1e3 + 1;
long long dp[N][N];
char s[N], t[N];
long long fun(long long i, long long j) {
  if (i < 0 || j < 0) return (long long)(1e18);
  if (dp[i][j] != -1) return dp[i][j];
  if (j == 0) return (dp[i][j] = i);
  if (i == 0) return (dp[i][j] = j);
  dp[i][j] = fun(i - 1, j - 1);
  if (s[i - 1] != t[j - 1]) {
    dp[i][j]++;
  }
  dp[i][j] = min(dp[i][j], fun(i, j - 1) + 1);
  dp[i][j] = min(dp[i][j], fun(i - 1, j) + 1);
  return dp[i][j];
}
void outPut(long long n, long long m) {
  if (n > 0 && m > 0 && s[n - 1] == t[m - 1] && dp[n][m] == dp[n - 1][m - 1])
    outPut(n - 1, m - 1);
  else if (n > 0 && m > 0 && dp[n][m] == dp[n - 1][m - 1] + 1) {
    outPut(n - 1, m - 1);
    printf("REPLACE %lld %c\n", m, t[m - 1]);
  } else if (m > 0 && dp[n][m] == dp[n][m - 1] + 1) {
    outPut(n, m - 1);
    printf("INSERT %lld %c\n", m, t[m - 1]);
  } else if (n > 0 && dp[n][m] == dp[n - 1][m] + 1) {
    outPut(n - 1, m);
    printf("DELETE %lld\n", m + 1);
  }
}
void solve() {
  memset(dp, -1, sizeof(dp));
  scanf("%s%s", &s, &t);
  long long ans = fun(strlen(s), strlen(t));
  printf("%lld\n", ans);
  outPut(strlen(s), strlen(t));
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  start = clock();
  cout << fixed << setprecision(10);
  for (long long i = 1; i <= t; ++i) {
    solve();
  }
  return 0;
}