#include <bits/stdc++.h>
int diru[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dirv[] = {-1, 0, 1, -1, 1, -1, 0, 1};
using namespace std;
template <class T>
T sq(T n) {
  return n * n;
}
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
bool inside(T a, T b, T c) {
  return a <= b && b <= c;
}
template <class T>
void setmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void setmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
T power(T N, T P) {
  return (P == 0) ? 1 : N * power(N, P - 1);
}
int dp[1010][1010];
int p[1010][1010][3];
char s[1010];
char t[1010];
int cal(int i, int j) {
  if (i < 0 && j < 0) return 0;
  if (i < 0) return j + 1;
  if (j < 0) return i + 1;
  if (dp[i][j] != -1) return dp[i][j];
  int cost, ret, tmp;
  if (s[i] == t[j])
    cost = 0;
  else
    cost = 1;
  ret = 1 + cal(i, j - 1);
  p[i][j][0] = 0;
  p[i][j][1] = j + 1;
  p[i][j][2] = t[j];
  tmp = 1 + cal(i - 1, j);
  if (ret > tmp) {
    ret = tmp;
    p[i][j][0] = 1;
    p[i][j][1] = j + 2;
    p[i][j][2] = s[i];
  }
  tmp = cal(i - 1, j - 1) + cost;
  if (ret > tmp) {
    ret = tmp;
    p[i][j][0] = 2;
    p[i][j][1] = j + 1;
    if (cost)
      p[i][j][2] = t[j];
    else
      p[i][j][2] = 0;
  }
  return dp[i][j] = ret;
}
void print(int i, int j) {
  if (i < 0 && j < 0) return;
  int k;
  if (i < 0) {
    for (k = 0; k < j + 1; k++) printf("INSERT %d %c\n", k + 1, t[k]);
    return;
  }
  if (j < 0) {
    for (k = i; k > -1; k--) printf("DELETE 1\n");
    return;
  }
  if (p[i][j][0] == 0) {
    print(i, j - 1);
    printf("INSERT %d %c\n", p[i][j][1], p[i][j][2]);
  } else if (p[i][j][0] == 1) {
    print(i - 1, j);
    printf("DELETE %d\n", p[i][j][1]);
  } else {
    print(i - 1, j - 1);
    if (p[i][j][2]) printf("REPLACE %d %c\n", p[i][j][1], p[i][j][2]);
  }
}
int main() {
  int i, j;
  while (scanf("%s%s", s, t) == 2) {
    int ls = strlen(s);
    int lt = strlen(t);
    for (i = 0; i < ls; i++)
      for (j = 0; j < lt; j++) dp[i][j] = -1;
    printf("%d\n", cal(ls - 1, lt - 1));
    print(ls - 1, lt - 1);
  }
  return 0;
}
