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 inf = 1000000005;
long long int llinf = 2000000000000000005LL;
long long int mod = 1000000007;
long long int mod9 = 1000000009;
double pi = 3.1415926535897;
double eps = 1e-15;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1}, dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
vector<bool> isprime;
vector<int> primes;
void seive(int n, bool wantlist = true) {
  isprime.resize(n + 1, true);
  isprime[0] = isprime[1] = false;
  int sq = sqrt(n + 1);
  for (int i = 2; i < sq + 1; i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= n; j += i) isprime[j] = false;
    }
  }
  for (int i = 2; wantlist && i <= n; i++) {
    if (isprime[i]) primes.push_back(i);
  }
}
template <class T>
inline T gcd(T a, T b) {
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
template <class T>
inline vector<T> operator+(vector<T>& a, vector<T>& b) {
  assert(a.size() == b.size());
  int n = a.size();
  vector<T> c(n);
  for (int i = 0; i < n; i++) c[i] = a[i] + b[i];
  return c;
}
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
inline long long int bexp(long long int x, long long int n,
                          long long int m = mod) {
  long long int res = 1;
  x %= m;
  while (n) {
    if (n & 1) res = res * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return res;
}
inline bool ispalin(string& str) {
  int n = str.length();
  for (int i = 0; i < n / 2; i++)
    if (str[i] != str[n - i - 1]) return false;
  return true;
}
int main() {
  string s, t;
  cin >> s >> t;
  int n = s.length(), m = t.length();
  vector<vector<int> > dp(n + 1, vector<int>(m + 1, inf));
  for (int i = 0; i < n + 1; i++)
    for (int j = 0; j < m + 1; j++) {
      if (i == 0 || j == 0)
        dp[i][j] = max(i, j);
      else {
        dp[i][j] = min((s[i - 1] != t[j - 1]) + dp[i - 1][j - 1],
                       1 + min(dp[i - 1][j], dp[i][j - 1]));
      }
    }
  vector<int> res;
  int i = n, j = m;
  while (i > 0 || j > 0) {
    if (i > 0 && dp[i][j] == 1 + dp[i - 1][j]) {
      res.push_back(0);
      i--;
    } else if (j > 0 && dp[i][j] == 1 + dp[i][j - 1]) {
      res.push_back(1);
      j--;
    } else if (i > 0 && j > 0 && s[i - 1] != t[j - 1] &&
               dp[i][j] == 1 + dp[i - 1][j - 1]) {
      res.push_back(2);
      i--;
      j--;
    } else {
      res.push_back(3);
      i--;
      j--;
    }
  }
  reverse(res.begin(), res.end());
  vector<string> ans;
  i = 1;
  j = 0;
  for (int x : res) {
    if (x == 0) {
      ans.push_back("DELETE " + to_string(i));
    } else if (x == 1) {
      ans.push_back("INSERT " + to_string(i) + " " + string(1, t[j]));
      i++;
      j++;
    } else if (x == 2) {
      ans.push_back("REPLACE " + to_string(i) + " " + string(1, t[j]));
      i++;
      j++;
    } else if (x == 3) {
      i++;
      j++;
    }
  }
  cout << dp[n][m] << endl;
  for (string str : ans) cout << str << endl;
}