#include <bits/stdc++.h>
using namespace std;
string s, t;
const int N = 1005;
int dp[N][N];
int solve(int i, int j) {
  if (i == s.size()) return t.size() - j;
  if (j == t.size()) return s.size() - i;
  int& ret = dp[i][j];
  if (ret != -1) return ret;
  ret = ((int)(1e9) + 7);
  if (s[i] == t[j]) ret = min(ret, solve(i + 1, j + 1));
  ret = min(ret, 1 + solve(i + 1, j));
  ret = min(ret, 1 + solve(i, j + 1));
  ret = min(ret, 1 + solve(i + 1, j + 1));
  return ret;
}
void recover(int i, int j, int k) {
  if (i == s.size()) {
    while (j < t.size()) cout << "INSERT " << k++ << " " << t[j++] << "\n";
    return;
  }
  if (j == t.size()) {
    for (; i < s.size(); ++i) cout << "DELETE " << k << "\n";
    return;
  }
  int val = dp[i][j];
  if (s[i] == t[j] && val == solve(i + 1, j + 1)) {
    recover(i + 1, j + 1, k + 1);
    return;
  }
  if (val == solve(i + 1, j) + 1) {
    cout << "DELETE " << k << "\n";
    recover(i + 1, j, k);
    return;
  }
  if (val == solve(i, j + 1) + 1) {
    cout << "INSERT " << k << " " << t[j] << "\n";
    recover(i, j + 1, k + 1);
    return;
  }
  if (val == solve(i + 1, j + 1) + 1) {
    cout << "REPLACE " << k << " " << t[j] << "\n";
    recover(i + 1, j + 1, k + 1);
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> t;
  memset(dp, -1, sizeof dp);
  cout << solve(0, 0) << "\n";
  recover(0, 0, 1);
  return 0;
}
