#include <bits/stdc++.h>
using namespace std;
int t;
int n[2];
char x[2][1005];
int dp[1005][1005];
queue<pair<char, pair<int, char> > > ans;
int main() {
  for (int a = 0; a < 2; a++) {
    scanf("%s", x[a] + 1);
    while (x[a][++n[a]] != 0) {
    }
  }
  for (int a = 0; a < n[0]; a++) dp[a][0] = a;
  for (int a = 0; a < n[1]; a++) dp[0][a] = a;
  for (int a = 1; a < n[0]; a++)
    for (int b = 1; b < n[1]; b++)
      dp[a][b] = min(dp[a - 1][b - 1] + (x[0][a] != x[1][b]),
                     min(dp[a][b - 1], dp[a - 1][b]) + 1);
  printf("%d\n", dp[--n[0]][--n[1]]);
  while (n[0] != 0 || n[1] != 0) {
    if (n[0] != 0 && dp[n[0]][n[1]] == dp[n[0] - 1][n[1]] + 1) {
      ans.push(make_pair(1, make_pair(n[0], 0)));
      n[0]--;
    } else if (n[1] != 0 && dp[n[0]][n[1]] == dp[n[0]][n[1] - 1] + 1) {
      ans.push(make_pair(0, make_pair(n[0] + 1, x[1][n[1]])));
      n[1]--;
    } else {
      if (dp[n[0]][n[1]] == dp[n[0] - 1][n[1] - 1] + 1)
        ans.push(make_pair(2, make_pair(n[0], x[1][n[1]])));
      n[0]--;
      n[1]--;
    }
  }
  while (!ans.empty()) {
    if (ans.front().first == 0)
      printf("INSERT %d %c\n", ans.front().second.first,
             ans.front().second.second);
    else if (ans.front().first == 1)
      printf("DELETE %d\n", ans.front().second.first);
    else
      printf("REPLACE %d %c\n", ans.front().second.first,
             ans.front().second.second);
    ans.pop();
  }
  return 0;
}
