#include <bits/stdc++.h>
using namespace std;
int n, m, k;
bool debug = false;
int dp[1005][1005];
char a[1005], b[1005];
int main() {
  scanf("%s%s", a + 1, b + 1);
  int n = strlen(a + 1);
  int m = strlen(b + 1);
  for (int i = 1; i <= n; i++) dp[i][0] = i;
  for (int i = 1; i <= m; i++) dp[0][i] = i;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      dp[i][j] = min(min(dp[i][j - 1], dp[i - 1][j]) + 1,
                     dp[i - 1][j - 1] + (a[i] != b[j]));
    }
  }
  printf("%d\n", dp[n][m]);
  while (n != 0 || m != 0) {
    if (m != 0 && dp[n][m] == dp[n][m - 1] + 1) {
      printf("INSERT %d %c\n", n + 1, b[m]);
      m--;
    } else if (n != 0 && dp[n][m] == dp[n - 1][m] + 1) {
      printf("DELETE %d\n", n);
      n--;
    } else if (a[n--] != b[m--]) {
      printf("REPLACE %d %c\n", n + 1, b[m + 1]);
    }
  }
  return 0;
}
