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;
void RD(int &x) { scanf("%d", &x); }
void RD(long long &x) { scanf("%I64d", &x); }
void RD(double &x) { scanf("%lf", &x); }
void RD(int &x, int &y) { scanf("%d%d", &x, &y); }
void RD(long long &x, long long &y) { scanf("%I64d%I64d", &x, &y); }
void RD(double &x, double &y) { scanf("%lf%lf", &x, &y); }
void RD(char *s) { scanf("%s", s); }
void RD(char &s) { scanf("%c", &s); }
void RD(string &s) { cin >> s; }
void PR(int x) { printf("%d\n", x); }
void PR(int x, int y) { printf("%d %d\n", x, y); }
void PR(long long x) { printf("%I64d\n", x); }
void PR(char x) { printf("%c\n", x); }
void PR(char *x) { printf("%s\n", x); }
void PR(string x) { cout << x << endl; }
const int inf = 1e9;
const long long mod = 1LL;
int dp[1010][1010];
char s1[1010], s2[1010];
int len1, len2;
int solve(int n, int m) {
  if (n == len1) return dp[n][m] = len2 - m;
  if (m == len2) return dp[n][m] = len1 - n;
  int &ret = dp[n][m];
  if (ret != inf) return ret;
  if (s1[n] == s2[m])
    ret = solve(n + 1, m + 1);
  else
    ret = min(min(1 + solve(n + 1, m + 1), 1 + solve(n, m + 1)),
              1 + solve(n + 1, m));
  return ret;
}
void path(int n, int m, int p, int q) {
  if (n == len1) {
    int i, j;
    for (i = m, j = q; i < len2; i++, j++)
      printf("INSERT %d %c\n", j + 1, s2[i]);
    return;
  }
  if (m == len2) {
    int i;
    for (i = n; i < len1; i++) printf("DELETE %d\n", p + 1);
    return;
  }
  if (s1[n] == s2[m]) return path(n + 1, m + 1, p + 1, q + 1);
  if (dp[n][m] == 1 + dp[n + 1][m + 1]) {
    printf("REPLACE %d %c\n", p + 1, s2[m]);
    return path(n + 1, m + 1, p + 1, q + 1);
  } else if (dp[n][m] == 1 + dp[n][m + 1]) {
    printf("INSERT %d %c\n", p + 1, s2[m]);
    return path(n, m + 1, p + 1, q + 1);
  } else {
    printf("DELETE %d\n", p + 1);
    return path(n + 1, m, p, q);
  }
}
int main() {
  int i, j;
  while (scanf("%s %s", s1, s2) == 2) {
    len1 = strlen(s1);
    len2 = strlen(s2);
    for ((i) = 0; (i) < (int)(len1 + 1); (i)++)
      for ((j) = 0; (j) < (int)(len2 + 1); (j)++) dp[i][j] = inf;
    PR(solve(0, 0));
    path(0, 0, 0, 0);
  }
  return 0;
}