#include <bits/stdc++.h>
using namespace std;
int dp[1000][1000];
string s1;
string s2;
int solve(int i = 0, int j = 0) {
  if (i == s1.size()) return (j == s2.size()) ? 0 : s2.size() - j;
  if (j == s2.size()) {
    return s1.size() - i;
  }
  if (dp[i][j] != -1) return dp[i][j];
  if (s1[i] == s2[j]) return dp[i][j] = solve(i + 1, j + 1);
  int ans = 1 + solve(i + 1, j);
  ans = min(ans, 1 + solve(i + 1, j + 1));
  ans = min(ans, 1 + solve(i, j + 1));
  return dp[i][j] = ans;
}
void get_output(int i = 0, int j = 0, int indx = 0) {
  if (j == s2.size() && i == s1.size()) return;
  if (i == s1.size()) {
    cout << "INSERT " << indx + 1 << " " << s2[j] << '\n';
    get_output(i, j + 1, indx + 1);
    return;
  }
  if (j == s2.size()) {
    cout << "DELETE " << indx + 1 << " " << '\n';
    get_output(i + 1, j, indx);
    return;
  }
  if (s1[i] == s2[j]) {
    get_output(i + 1, j + 1, indx + 1);
    return;
  }
  char c = 'd';
  int ans = 1 + solve(i + 1, j);
  if (ans > 1 + solve(i + 1, j + 1)) {
    ans = 1 + solve(i + 1, j + 1);
    c = 'r';
  }
  if (ans > 1 + solve(i, j + 1)) {
    ans = 1 + solve(i, j + 1);
    c = 'i';
  }
  if (c == 'd') {
    cout << "DELETE " << indx + 1 << " " << '\n';
    get_output(i + 1, j, indx);
  } else if (c == 'r') {
    cout << "REPLACE " << indx + 1 << " " << s2[j] << '\n';
    get_output(i + 1, j + 1, indx + 1);
  } else {
    cout << "INSERT " << indx + 1 << " " << s2[j] << '\n';
    get_output(i, j + 1, indx + 1);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  memset(dp, -1, sizeof dp);
  cin >> s1 >> s2;
  cout << solve() << '\n';
  get_output();
}
