#include <bits/stdc++.h>
using namespace std;
const int maxMN = 1000 + 10;
int d[maxMN][maxMN], n, m;
string a, b;
void pp(int i, int j) {
  if (i || j) {
    if (a[i - 1] == b[j - 1] && i >= 1 && j >= 1) {
      pp(i - 1, j - 1);
    } else if ((d[i][j] - 1) == d[i - 1][j]) {
      pp(i - 1, j);
      cout << "DELETE " << j + 1 << endl;
    } else if ((d[i][j] - 1) == d[i][j - 1]) {
      pp(i, j - 1);
      cout << "INSERT " << j << ' ' << b[j - 1] << endl;
    } else if ((d[i][j] - 1) == d[i - 1][j - 1]) {
      pp(i - 1, j - 1);
      cout << "REPLACE " << j << ' ' << b[j - 1] << endl;
    }
  }
}
int main() {
  cin >> a >> b;
  n = a.size();
  m = b.size();
  for (int i = 1; i <= n; i++) d[i][0] = i;
  for (int j = 1; j <= m; j++) d[0][j] = j;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i - 1] == b[j - 1]) {
        d[i][j] = d[i - 1][j - 1];
      } else {
        d[i][j] = min(d[i - 1][j], min(d[i][j - 1], d[i - 1][j - 1])) + 1;
      }
    }
  }
  cout << d[n][m] << endl;
  pp(n, m);
  return 0;
}
