#include <bits/stdc++.h>
using namespace std;
vector<pair<int, char> > solve;
int dp[1005][1005], steps[1005][1005];
int ans = 1;
char a[1005], b[1005];
void truyvet(int i, int j) {
  if (steps[i][j] == 2) {
    truyvet(i - 1, j - 1);
    cout << "REPLACE " << ans << " " << b[j - 1] << endl;
    ans++;
  } else if (steps[i][j] == 1) {
    truyvet(i, j - 1);
    cout << "INSERT " << ans << " " << b[j - 1] << endl;
    ans++;
  } else if (steps[i][j] == 3) {
    truyvet(i - 1, j);
    cout << "DELETE " << ans << endl;
  } else if (steps[i][j] == 4) {
    truyvet(i - 1, j - 1);
    ans++;
  }
}
int main() {
  scanf("%s %s", a, b);
  int n = strlen(a), m = strlen(b);
  for (int i = 1; i <= n; i += 1) {
    dp[i][0] = i;
    steps[i][0] = 3;
  }
  for (int i = 1; i <= m; i++) {
    dp[0][i] = i;
    steps[0][i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i - 1] == b[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1];
        steps[i][j] = 4;
      } else {
        dp[i][j] = min(dp[i - 1][j], min(dp[i][j - 1], dp[i - 1][j - 1])) + 1;
        if (dp[i][j] == dp[i][j - 1] + 1)
          steps[i][j] = 1;
        else if (dp[i][j] == dp[i - 1][j - 1] + 1)
          steps[i][j] = 2;
        else if (dp[i][j] == dp[i - 1][j] + 1) {
          steps[i][j] = 3;
        }
      }
    }
  }
  cout << dp[n][m] << endl;
  truyvet(n, m);
}
