#include <bits/stdc++.h>
using namespace std;
string s, t;
int table[1002][1002] = {};
int main() {
  ios_base::sync_with_stdio(false);
  cin >> s >> t;
  for (int i = 0; i <= s.size(); ++i) {
    for (int j = 0; j <= t.size(); ++j) {
      if (!i)
        table[i][j] = j;
      else if (!j)
        table[i][j] = i;
      else if (s[i - 1] == t[j - 1]) {
        table[i][j] = table[i - 1][j - 1];
      } else {
        table[i][j] =
            1 + min(table[i - 1][j - 1], min(table[i - 1][j], table[i][j - 1]));
      }
    }
  }
  cout << table[s.size()][t.size()] << endl;
  int i = s.size(), j = t.size();
  while (i || j) {
    if (table[i][j] == 1 + table[i][j - 1] && j) {
      cout << "INSERT " << i + 1 << " " << t[j - 1] << endl;
      j--;
    } else if (table[i][j] == 1 + table[i - 1][j] && i) {
      cout << "DELETE " << i << endl;
      i--;
    } else if (table[i][j] == 1 + table[i - 1][j - 1]) {
      cout << "REPLACE " << i << " " << t[j - 1] << endl;
      i--;
      j--;
    } else {
      i--;
      j--;
    }
  }
  return 0;
}
