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;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  string sep;
  for (const auto &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
template <typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr) {
  os << '{';
  string sep;
  for (const auto &x : arr) os << sep << x, sep = ", ";
  return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
const long long N = 1000 + 5, inf = 1e17;
string s, t;
long long n, m, dp[N][N];
long long go(long long i, long long j) {
  if (i == n) return m - j;
  if (j == m) return n - i;
  long long &ans = dp[i][j];
  if (~ans) return ans;
  ans = inf;
  long long c1 = 1 + go(i, j + 1);
  ans = min(ans, c1);
  long long c2 = 1 + go(i + 1, j);
  ans = min(ans, c2);
  long long c3 = (s[i] != t[j]) + go(i + 1, j + 1);
  ans = min(ans, c3);
  return ans;
}
void trace(long long i, long long j, long long add) {
  if (i == n) {
    for (long long id = j; id < m; id++) {
      cout << "INSERT " << i + add + 1 << " " << t[id] << "\n";
      add++;
    }
    return;
  }
  if (j == m) {
    for (long long id = i; id < n; id++) {
      cout << "DELETE " << i + add + 1 << "\n";
    }
    return;
  }
  long long ans = go(i, j);
  long long c1 = 1 + go(i, j + 1);
  if (c1 == ans) {
    cout << "INSERT " << i + add + 1 << " " << t[j] << "\n";
    return trace(i, j + 1, add + 1);
  }
  long long c2 = 1 + go(i + 1, j);
  if (c2 == ans) {
    cout << "DELETE " << i + add + 1 << "\n";
    return trace(i + 1, j, add - 1);
  }
  long long c3 = (s[i] != t[j]) + go(i + 1, j + 1);
  if (c3 == ans) {
    if (s[i] != t[j]) {
      cout << "REPLACE " << i + add + 1 << " " << t[j] << "\n";
      return trace(i + 1, j + 1, add);
    }
    return trace(i + 1, j + 1, add);
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> s >> t;
  n = (long long)(s.size()), m = (long long)(t.size());
  ;
  memset(dp, -1, sizeof(dp));
  long long ans = go(0, 0);
  cout << ans << "\n";
  trace(0, 0, 0);
}