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 dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const double EPS = (1e-7);
const long long mod = (1e9 + 9), OO = 2e18, N = 2020;
long long gcd(long long a, long long b) { return !b ? abs(a) : gcd(b, a % b); }
long long lcm(long long a, long long b) { return abs(a / gcd(a, b)) * b; }
long long Ceil(long long x, long long y) { return (x + y - 1) / y; }
void run(string s) {}
void fast() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long n, m, t = 1, kk, ggg, kkk;
int dp[1001][1001];
string s, s1;
int solve(int x, int y) {
  if (x == n && y == m) return 0;
  if (x == n) return m - y;
  if (y == m) return n - x;
  int& ret = dp[x][y];
  if (~ret) return ret;
  ret = 1e7;
  if (s[x] == s1[y]) ret = min(solve(x + 1, y + 1), ret);
  ret = min(solve(x + 1, y) + 1, ret);
  ret = min(solve(x, y + 1) + 1, ret);
  ret = min(solve(x + 1, y + 1) + 1, ret);
  return ret;
}
int pr = 1;
void build(int x, int y) {
  if (x == n) {
    for (int i = y; i < m; i++) {
      cout << "INSERT " << pr++ << " " << s1[i] << '\n';
    }
    return;
  }
  if (y == m) {
    for (int i = x; i < n; i++) {
      cout << "DELETE " << pr << '\n';
    }
    return;
  }
  if (s[x] == s1[y]) {
    pr++;
    build(x + 1, y + 1);
    return;
  }
  long long op = solve(x, y);
  if (op == solve(x + 1, y + 1) + 1) {
    cout << "REPLACE " << pr++ << " " << s1[y] << '\n';
    build(x + 1, y + 1);
    return;
  }
  if (op == solve(x + 1, y) + 1) {
    cout << "DELETE " << pr << '\n';
    build(x + 1, y);
    return;
  }
  if (op == solve(x, y + 1) + 1) {
    cout << "INSERT " << pr++ << " " << s1[y] << '\n';
    build(x, y + 1);
    return;
  }
}
int main() {
  run("still");
  fast();
  memset(dp, -1, sizeof dp);
  cin >> s >> s1;
  n = s.size(), m = s1.size();
  cout << solve(0, 0) << '\n';
  build(0, 0);
}