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;
struct Counter {
  static int k;
  Counter() { k++; }
  ~Counter() { k--; }
};
int Counter::k = 0;
template <typename T>
void pr(const string& name, T t) {
  cout << name << " = " << t << endl;
}
template <typename T, typename... Types>
void pr(const string& names, T t, Types... rest) {
  auto comma_pos = names.find(',');
  cout << names.substr(0, comma_pos) << " = " << t << ", ";
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest...);
}
void mod(long long& a, long long b) {
  a %= b;
  if (a < 0) a += b;
}
const long long MOD = 1000000007;
int D[1005][1005];
pair<int, int> From[1005][1005];
string S, T;
int main() {
  cin >> S >> T;
  From[0][0] = {-1, -1};
  for (int i = (1); i <= (1000); i++) {
    D[0][i] = D[i][0] = i;
    From[0][i] = {0, i - 1};
    From[i][0] = {i - 1, 0};
  }
  for (int i = (1); i <= (((int)S.size())); i++)
    for (int j = (1); j <= (((int)T.size())); j++) {
      D[i][j] = D[i - 1][j] + 1;
      From[i][j] = {i - 1, j};
      if (D[i][j - 1] + 1 < D[i][j])
        D[i][j] = D[i][j - 1] + 1, From[i][j] = {i, j - 1};
      if (D[i - 1][j - 1] + (S[i - 1] != T[j - 1] ? 1 : 0) < D[i][j])
        D[i][j] = D[i - 1][j - 1] + (S[i - 1] != T[j - 1] ? 1 : 0),
        From[i][j] = {i - 1, j - 1};
    }
  int i = ((int)S.size()), j = ((int)T.size());
  vector<pair<int, int>> v;
  while (i >= 0 || j >= 0) {
    v.push_back({i, j});
    int ni = From[i][j].first;
    int nj = From[i][j].second;
    i = ni, j = nj;
  }
  reverse(v.begin(), v.end());
  cout << D[((int)S.size())][((int)T.size())] << "\n";
  int d = 0, ins = 0;
  for (int i = (1); i <= (((int)v.size()) - 1); i++) {
    if (v[i - 1].first == v[i].first - 1 &&
        v[i - 1].second == v[i].second - 1) {
      if (S[v[i].first - 1] != T[v[i].second - 1])
        cout << "REPLACE " << v[i].second << " " << T[v[i].second - 1] << "\n";
    } else if (v[i - 1].first != v[i].first)
      cout << "DELETE " << v[i].first - d + ins << "\n", d++;
    else
      cout << "INSERT " << v[i].second << " " << T[v[i].second - 1] << "\n",
          ins++;
  }
}