#include <bits/stdc++.h>
using namespace std;
const int inf = 100000000;
char a[1005], b[1005];
int f[1001][1001], g[1001][1001];
int main(void) {
  scanf("%s", a + 1);
  scanf("%s", b + 1);
  int n = (int)strlen(a + 1), m = (int)strlen(b + 1);
  f[0][0] = 0;
  g[0][0] = -2;
  for (int i = 1; i <= m; ++i) {
    f[0][i] = i;
    g[0][i] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    f[i][0] = i;
    g[i][0] = -1;
    for (int j = 1; j <= m; ++j) {
      f[i][j] = inf;
      if (a[i] == b[j]) {
        if (f[i - 1][j - 1] < f[i][j]) {
          f[i][j] = f[i - 1][j - 1];
          g[i][j] = 0;
        }
      } else {
        if (f[i - 1][j - 1] + 1 < f[i][j]) {
          f[i][j] = f[i - 1][j - 1] + 1;
          g[i][j] = 0;
        }
      }
      if (f[i][j - 1] + 1 < f[i][j]) {
        f[i][j] = f[i][j - 1] + 1;
        g[i][j] = 1;
      }
      if (f[i - 1][j] + 1 < f[i][j]) {
        f[i][j] = f[i - 1][j] + 1;
        g[i][j] = -1;
      }
    }
  }
  printf("%d\n", f[n][m]);
  int p = n, q = m;
  while (g[p][q] > -2) {
    if (g[p][q] == -1) {
      printf("DELETE %d\n", p);
      --p;
    } else if (g[p][q] == 0) {
      if (a[p] != b[q]) printf("REPLACE %d %c\n", p, b[q]);
      --p;
      --q;
    } else if (g[p][q] == 1) {
      printf("INSERT %d %c\n", p + 1, b[q]);
      --q;
    }
  }
  return 0;
}
