#include <bits/stdc++.h>
using namespace std;
int inf = 1000000005;
long long int llinf = 2000000000000000005LL;
long long int mod = 1000000007;
long long int mod9 = 1000000009;
double pi = 3.1415926535897;
double eps = 1e-15;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1}, dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
vector<bool> isprime;
vector<int> primes;
void seive(int n, bool wantlist = true) {
  isprime.resize(n + 1, true);
  isprime[0] = isprime[1] = false;
  int sq = sqrt(n + 1);
  for (int i = 2; i < sq + 1; i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= n; j += i) isprime[j] = false;
    }
  }
  for (int i = 2; wantlist && i <= n; i++) {
    if (isprime[i]) primes.push_back(i);
  }
}
template <class T>
inline T gcd(T a, T b) {
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
template <class T>
inline vector<T> operator+(vector<T>& a, vector<T>& b) {
  assert(a.size() == b.size());
  int n = a.size();
  vector<T> c(n);
  for (int i = 0; i < n; i++) c[i] = a[i] + b[i];
  return c;
}
int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }
inline long long int bexp(long long int x, long long int n,
                          long long int m = mod) {
  long long int res = 1;
  x %= m;
  while (n) {
    if (n & 1) res = res * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return res;
}
inline bool ispalin(string& str) {
  int n = str.length();
  for (int i = 0; i < n / 2; i++)
    if (str[i] != str[n - i - 1]) return false;
  return true;
}
int main() {
  string s, t;
  cin >> s >> t;
  int n = s.length(), m = t.length();
  vector<vector<int> > dp(n + 1, vector<int>(m + 1, inf));
  for (int i = 0; i < n + 1; i++)
    for (int j = 0; j < m + 1; j++) {
      if (i == 0 || j == 0)
        dp[i][j] = max(i, j);
      else {
        dp[i][j] = min((s[i - 1] != t[j - 1]) + dp[i - 1][j - 1],
                       1 + min(dp[i - 1][j], dp[i][j - 1]));
      }
    }
  vector<int> res;
  int i = n, j = m;
  while (i > 0 || j > 0) {
    if (i > 0 && dp[i][j] == 1 + dp[i - 1][j]) {
      res.push_back(0);
      i--;
    } else if (j > 0 && dp[i][j] == 1 + dp[i][j - 1]) {
      res.push_back(1);
      j--;
    } else if (i > 0 && j > 0 && s[i - 1] != t[j - 1] &&
               dp[i][j] == 1 + dp[i - 1][j - 1]) {
      res.push_back(2);
      i--;
      j--;
    } else {
      res.push_back(3);
      i--;
      j--;
    }
  }
  reverse(res.begin(), res.end());
  vector<string> ans;
  i = 1;
  j = 0;
  for (int x : res) {
    if (x == 0) {
      ans.push_back("DELETE " + to_string(i));
    } else if (x == 1) {
      ans.push_back("INSERT " + to_string(i) + " " + string(1, t[j]));
      i++;
      j++;
    } else if (x == 2) {
      ans.push_back("REPLACE " + to_string(i) + " " + string(1, t[j]));
      i++;
      j++;
    } else if (x == 3) {
      i++;
      j++;
    }
  }
  cout << dp[n][m] << endl;
  for (string str : ans) cout << str << endl;
}
