#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s;
  cin >> t;
  int n = s.size(), m = t.size();
  vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i == 0)
        dp[i][j] = j;
      else if (j == 0)
        dp[i][j] = i;
      else {
        dp[i][j] = min({dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]}) + 1;
        if (s[i - 1] == t[j - 1]) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
      }
    }
  }
  vector<tuple<string, int, char>> ans;
  int i = n, j = m;
  while (i > 0 || j > 0) {
    if (i > 0 && j > 0 && s[i - 1] == t[j - 1] &&
        dp[i][j] == dp[i - 1][j - 1]) {
      i--, j--;
    } else if (i > 0 && j > 0 && dp[i][j] == dp[i - 1][j - 1] + 1) {
      ans.emplace_back("REPLACE", i, t[j - 1]);
      i--, j--;
    } else if (i > 0 && dp[i][j] == dp[i - 1][j] + 1) {
      ans.emplace_back("DELETE", i, '$');
      i--;
    } else if (j > 0 && dp[i][j] == dp[i][j - 1] + 1) {
      ans.emplace_back("INSERT", i + 1, t[j - 1]);
      j--;
    } else
      assert(0);
  }
  cout << ans.size() << '\n';
  for (auto &[a, b, c] : ans) {
    if (c == '$')
      cout << a << ' ' << b << '\n';
    else
      cout << a << ' ' << b << ' ' << c << '\n';
  }
}
