#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1;
  string s2;
  while (cin >> s1 >> s2) {
    int n = s1.length(), m = s2.length();
    int dp[n + 1][m + 1];
    for (int i = 0; i < n + 1; i++) dp[i][0] = i;
    for (int i = 0; i < m + 1; i++) dp[0][i] = i;
    for (int i = 1; i < n + 1; i++) {
      for (int j = 1; j < m + 1; j++) {
        if (s1[i - 1] == s2[j - 1])
          dp[i][j] = dp[i - 1][j - 1];
        else
          dp[i][j] = min(min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1;
      }
    }
    cout << dp[n][m] << endl;
    int i = n, j = m;
    while (i >= 0 && j >= 0) {
      if (dp[i][j - 1] == dp[i][j] - 1) {
        cout << "INSERT " + to_string(i + 1) + " " + s2[j - 1] << endl;
        j--;
      } else if (dp[i - 1][j] == dp[i][j] - 1) {
        cout << "DELETE " + to_string(i) << endl;
        i--;
      } else if (dp[i - 1][j - 1] == dp[i][j] - 1 && s1[i - 1] != s2[j - 1]) {
        cout << "REPLACE " + to_string(i) + " " + s2[j - 1] << endl;
        i--, j--;
      } else
        i--, j--;
    }
  }
  return 0;
}
