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;
const int MAX = 1005;
char s1[MAX], s2[MAX];
int n1, n2;
valarray<int> solve(int st1, int en1, int st2, int en2, int inc) {
  int len2 = (en2 - st2) * inc + 1;
  valarray<int> dp[2] = {valarray<int>(n2 + 2), valarray<int>(n2 + 2)};
  int l2 = st2 - inc, x = 0;
  do {
    l2 += inc, x++;
    dp[(st1 - inc) & 1][l2] = x;
  } while (l2 != en2);
  int l1 = st1 - inc;
  x = 0;
  do {
    l1 += inc, x++;
    dp[l1 & 1][st2 - inc] = x;
    int l2 = st2 - inc;
    do {
      l2 += inc;
      int &res = dp[l1 & 1][l2];
      int i1 = l1 - 1, i2 = l2 - 1;
      res = dp[(l1 - inc) & 1][l2 - inc] + (s1[i1] != s2[i2]);
      res = min(res, 1 + dp[(l1 - inc) & 1][l2]);
      res = min(res, 1 + dp[(l1)&1][l2 - inc]);
    } while (l2 != en2);
  } while (l1 != en1);
  return dp[en1 & 1];
}
int cnt = 0;
void insert(int s, int e) {
  for (int i = s; i <= e; i++) {
    printf("INSERT %d %c\n", i, s2[i - 1]);
    ++cnt;
  }
}
void del(int pos, int c) {
  while (c--) {
    printf("DELETE %d\n", pos);
    ++cnt;
  }
}
void hirschberg(int st1, int en1, int st2, int en2) {
  if (en1 < st1) {
    for (int i = st2; i <= en2; ++i) {
      printf("INSERT %d %c\n", i, s2[i - 1]);
      ++cnt;
    }
    return;
  }
  if (en2 < st2) {
    for (int i = st1; i <= en1; ++i) {
      printf("DELETE %d\n", st2);
      ++cnt;
    }
    return;
  }
  if (st1 == en1) {
    for (int i = st2; i <= en2; ++i) {
      if (s1[st1 - 1] == s2[i - 1]) {
        insert(st2, i - 1);
        insert(i + 1, en2);
        return;
      }
    }
    printf("REPLACE %d %c\n", st2, s2[st2 - 1]);
    ++cnt;
    insert(st2 + 1, en2);
    return;
  }
  if (st2 == en2) {
    for (int i = st1; i <= en1; i++) {
      if (s1[i - 1] == s2[st2 - 1]) {
        del(st2, i - st1);
        del(st2 + 1, en1 - i);
        return;
      }
    }
    printf("REPLACE %d %c\n", st2, s2[st2 - 1]);
    ++cnt;
    del(st2 + 1, en1 - st1);
    return;
  }
  int mid = (st1 + en1) / 2;
  valarray<int> res1 = solve(st1, mid, st2, en2, 1);
  valarray<int> res2 = solve(en1, mid + 1, en2, st2, -1);
  int mn = 1e7, bi;
  for (int i = st2 - 1; i <= en2; i++) {
    if (res1[i] + res2[i + 1] < mn) {
      mn = res1[i] + res2[i + 1];
      bi = i;
    }
  }
  hirschberg(st1, mid, st2, bi);
  hirschberg(mid + 1, en1, bi + 1, en2);
}
int main() {
  scanf("%s %s", s1, s2);
  n1 = strlen(s1);
  n2 = strlen(s2);
  int ans = solve(1, n1, 1, n2, 1)[n2];
  printf("%d\n", ans);
  hirschberg(1, n1, 1, n2);
  if (ans != cnt) printf("#");
}