#include <bits/stdc++.h>
using namespace std;
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
inline int addmod(int x, int y) {
  return (x % 1000000007 + y % 1000000007) % 1000000007;
}
inline int submod(int x, int y) {
  return (x % 1000000007 - y % 1000000007 + 1000000007) % 1000000007;
}
inline int mulmod(int x, int y) {
  return (x % 1000000007 * 1LL * y % 1000000007) % 1000000007;
}
inline int nextSubMask(int i, int mask) { return (i - 1) & mask; }
void we_r_done() {
  cout << "NO";
  exit(0);
}
void debug(bool ok, string mssg) {
  if (ok) return;
  cout << mssg;
  exit(0);
}
struct Operation {
  string name;
  int pos;
  char c;
  Operation(string n, int p, char cc) {
    name = n;
    pos = p;
    c = cc;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  s = "$" + s;
  t = "$" + t;
  int dp[n + 1][m + 1];
  dp[0][0] = 0;
  for (int j = 1; j <= m; j++) {
    dp[0][j] = j;
    for (int i = 1; i <= n; i++) {
      dp[i][0] = i;
      if (s[i] == t[j]) {
        dp[i][j] = dp[i - 1][j - 1];
      } else {
        dp[i][j] = min(dp[i - 1][j - 1], min(dp[i][j - 1], dp[i - 1][j])) + 1;
      }
    }
  }
  stack<Operation> stk;
  for (int i = n, j = m; i || j;) {
    if (s[i] == t[j]) {
      j--;
      i--;
    } else if (i && j && dp[i][j] == dp[i - 1][j - 1] + 1) {
      stk.push(Operation("REPLACE", i, t[j]));
      j--;
      i--;
    } else if (i && dp[i][j] == dp[i - 1][j] + 1) {
      stk.push(Operation("DELETE", i, '#'));
      i--;
    } else if (j && dp[i][j] == dp[i][j - 1] + 1) {
      stk.push(Operation("INSERT", i + 1, t[j]));
      j--;
    } else
      break;
  }
  int now = 0;
  assert(dp[n][m] == stk.size());
  cout << stk.size() << endl;
  while (stk.size()) {
    Operation op = stk.top();
    stk.pop();
    cout << op.name << " " << op.pos + now;
    if (op.name != "DELETE") cout << " " << op.c;
    cout << endl;
    if (op.name[0] == 'D')
      now--;
    else if (op.name[0] == 'I')
      now++;
  }
  assert(stk.size() == 0);
  return 0;
}
