#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  string sep;
  for (const auto &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
template <typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr) {
  os << '{';
  string sep;
  for (const auto &x : arr) os << sep << x, sep = ", ";
  return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
const long long N = 1000 + 5, inf = 1e17;
string s, t;
long long n, m, dp[N][N];
long long go(long long i, long long j) {
  if (i == n) return m - j;
  if (j == m) return n - i;
  long long &ans = dp[i][j];
  if (~ans) return ans;
  ans = inf;
  long long c1 = 1 + go(i, j + 1);
  ans = min(ans, c1);
  long long c2 = 1 + go(i + 1, j);
  ans = min(ans, c2);
  long long c3 = (s[i] != t[j]) + go(i + 1, j + 1);
  ans = min(ans, c3);
  return ans;
}
void trace(long long i, long long j, long long add) {
  if (i == n) {
    for (long long id = j; id < m; id++) {
      cout << "INSERT " << i + add + 1 << " " << t[id] << "\n";
      add++;
    }
    return;
  }
  if (j == m) {
    for (long long id = i; id < n; id++) {
      cout << "DELETE " << i + add + 1 << "\n";
    }
    return;
  }
  long long ans = go(i, j);
  long long c1 = 1 + go(i, j + 1);
  if (c1 == ans) {
    cout << "INSERT " << i + add + 1 << " " << t[j] << "\n";
    return trace(i, j + 1, add + 1);
  }
  long long c2 = 1 + go(i + 1, j);
  if (c2 == ans) {
    cout << "DELETE " << i + add + 1 << "\n";
    return trace(i + 1, j, add - 1);
  }
  long long c3 = (s[i] != t[j]) + go(i + 1, j + 1);
  if (c3 == ans) {
    if (s[i] != t[j]) {
      cout << "REPLACE " << i + add + 1 << " " << t[j] << "\n";
      return trace(i + 1, j + 1, add);
    }
    return trace(i + 1, j + 1, add);
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> s >> t;
  n = (long long)(s.size()), m = (long long)(t.size());
  ;
  memset(dp, -1, sizeof(dp));
  long long ans = go(0, 0);
  cout << ans << "\n";
  trace(0, 0, 0);
}
