#include <bits/stdc++.h>
using namespace std;
long long int dp[2001][2001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string a, b;
  cin >> a >> b;
  memset(dp, -1, sizeof dp);
  for (int i = 0; i <= a.size(); i++) {
    for (int j = 0; j <= b.size(); j++) {
      if (!i) {
        dp[i][j] = j;
        continue;
      }
      if (!j) {
        dp[i][j] = i;
        continue;
      }
      if (a[i - 1] == b[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[a.size()][b.size()] << endl;
  for (int i = a.size(), j = b.size(); i > 0 || j > 0;) {
    if (dp[i][j] == 1 + dp[i][j - 1]) {
      cout << "INSERT " << i + 1 << " " << b[j - 1] << endl;
      j--;
    } else if (dp[i][j] == 1 + dp[i - 1][j] && i) {
      cout << "DELETE " << i << endl;
      i--;
    } else if (dp[i][j] == 1 + dp[i - 1][j - 1]) {
      cout << "REPLACE " << i << " " << b[j - 1] << endl;
      i--;
      j--;
    } else {
      i--;
      j--;
    }
  }
}
