#include <bits/stdc++.h>
using namespace std;
void RD(int &x) { scanf("%d", &x); }
void RD(long long &x) { scanf("%I64d", &x); }
void RD(double &x) { scanf("%lf", &x); }
void RD(int &x, int &y) { scanf("%d%d", &x, &y); }
void RD(long long &x, long long &y) { scanf("%I64d%I64d", &x, &y); }
void RD(double &x, double &y) { scanf("%lf%lf", &x, &y); }
void RD(char *s) { scanf("%s", s); }
void RD(char &s) { scanf("%c", &s); }
void RD(string &s) { cin >> s; }
void PR(int x) { printf("%d\n", x); }
void PR(int x, int y) { printf("%d %d\n", x, y); }
void PR(long long x) { printf("%I64d\n", x); }
void PR(char x) { printf("%c\n", x); }
void PR(char *x) { printf("%s\n", x); }
void PR(string x) { cout << x << endl; }
const int inf = 1e9;
const long long mod = 1LL;
int dp[1010][1010];
char s1[1010], s2[1010];
int len1, len2;
int solve(int n, int m) {
  if (n == len1) return dp[n][m] = len2 - m;
  if (m == len2) return dp[n][m] = len1 - n;
  int &ret = dp[n][m];
  if (ret != inf) return ret;
  if (s1[n] == s2[m])
    ret = solve(n + 1, m + 1);
  else
    ret = min(min(1 + solve(n + 1, m + 1), 1 + solve(n, m + 1)),
              1 + solve(n + 1, m));
  return ret;
}
void path(int n, int m, int p, int q) {
  if (n == len1) {
    int i, j;
    for (i = m, j = q; i < len2; i++, j++)
      printf("INSERT %d %c\n", j + 1, s2[i]);
    return;
  }
  if (m == len2) {
    int i;
    for (i = n; i < len1; i++) printf("DELETE %d\n", p + 1);
    return;
  }
  if (s1[n] == s2[m]) return path(n + 1, m + 1, p + 1, q + 1);
  if (dp[n][m] == 1 + dp[n + 1][m + 1]) {
    printf("REPLACE %d %c\n", p + 1, s2[m]);
    return path(n + 1, m + 1, p + 1, q + 1);
  } else if (dp[n][m] == 1 + dp[n][m + 1]) {
    printf("INSERT %d %c\n", p + 1, s2[m]);
    return path(n, m + 1, p + 1, q + 1);
  } else {
    printf("DELETE %d\n", p + 1);
    return path(n + 1, m, p, q);
  }
}
int main() {
  int i, j;
  while (scanf("%s %s", s1, s2) == 2) {
    len1 = strlen(s1);
    len2 = strlen(s2);
    for ((i) = 0; (i) < (int)(len1 + 1); (i)++)
      for ((j) = 0; (j) < (int)(len2 + 1); (j)++) dp[i][j] = inf;
    PR(solve(0, 0));
    path(0, 0, 0, 0);
  }
  return 0;
}
