#include <bits/stdc++.h>
long long mod = 1e9 + 7;
int spf[100001];
using namespace std;
void primeFactors(long long n, vector<long long> &vec) {
  while (n % 2 == 0) {
    vec.push_back(2);
    n = n / 2;
  }
  for (long long i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      vec.push_back(i);
      n = n / i;
    }
  }
  if (n > 2) {
    vec.push_back(n);
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
long long Lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }
tuple<long long, long long, long long> getL(complex<long double> p1,
                                            complex<long double> p2) {
  long long a, b, c;
  a = p2.imag() - p1.imag();
  b = p1.real() - p2.real();
  c = -a * p1.real() - b * p1.imag();
  long long gcdres = abs(gcd(a, gcd(b, c)));
  if (a < 0 || a == 0 && b < 0) {
    gcdres *= -1;
  }
  a /= gcdres;
  b /= gcdres;
  c /= gcdres;
  return tuple<long long, long long, long long>(a, b, c);
}
long long fastpow(long long base, long long pow) {
  if (!base) return 0;
  if (!pow) return 1;
  if (pow == 1) return base;
  long long x = fastpow(base, pow / 2) % mod;
  x *= x;
  x %= mod;
  if (pow % 2) x *= base;
  return x % mod;
}
long long inverse(long long x) { return fastpow(x, mod - 2) % mod; }
long double disty(pair<double, double> a, pair<double, double> b) {
  return sqrt(pow(b.second - a.second, 2.0) + pow(b.first - a.first, 2.0));
}
void factorize(long long x, set<long long> &ss) {
  while (x % 2 == 0) ss.insert(2), x /= 2;
  for (int i = 3; i <= sqrt(x); i += 2)
    while (x % i == 0) ss.insert(i), x /= i;
  if (x > 2) ss.insert(x);
}
void SieveOfEratosthenes(long long n, bool prime[]) {
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
void divisors(long long n, vector<long long> &vec) {
  for (long long i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0 && i != sqrt(n)) {
      vec.push_back(i);
      vec.push_back(n / i);
    } else if (n % i == 0) {
      vec.push_back(i);
    }
  }
}
bool isprime(long long n) {
  if (n == 1) {
    return false;
  }
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
complex<long double> rot(complex<long double> p, long double angle) {
  return (p * polar((long double)1.0, angle));
}
complex<long double> rotA(complex<long double> p, complex<long double> A,
                          long double angle) {
  return (((p - A) * polar((long double)1, angle)) + A);
}
long double distance(complex<long double> a, complex<long double> b) {
  long double x1 = a.real(), y1 = a.imag(), x2 = b.real(), y2 = b.imag();
  return pow(y2 - y1, 2) + pow(x2 - x1, 2);
}
int distSq(pair<long long, long long> p, pair<long long, long long> q) {
  return (p.first - q.first) * (p.first - q.first) +
         (p.second - q.second) * (p.second - q.second);
}
bool isSquare(pair<long long, long long> p1, pair<long long, long long> p2,
              pair<long long, long long> p3, pair<long long, long long> p4) {
  long long d2 = distSq(p1, p2);
  long long d3 = distSq(p1, p3);
  long long d4 = distSq(p1, p4);
  if (d2 == d3 && 2 * d2 == d4 && 2 * d2 == distSq(p2, p3)) {
    int d = distSq(p2, p4);
    return (d == distSq(p3, p4) && d == d2);
  }
  if (d3 == d4 && 2 * d3 == d2 && 2 * d3 == distSq(p3, p4)) {
    int d = distSq(p2, p3);
    return (d == distSq(p2, p4) && d == d3);
  }
  if (d2 == d4 && 2 * d2 == d3 && 2 * d2 == distSq(p2, p4)) {
    int d = distSq(p2, p3);
    return (d == distSq(p3, p4) && d == d2);
  }
  return false;
}
long long FP(long long base, long long power, long long m) {
  if (power == 0) {
    return 1;
  } else if (power % 2 == 0) {
    long long res = FP(base, power / 2, m);
    return (res % m * res % m) % m;
  } else {
    long long res = FP(base, power / 2, m);
    return ((((base % m * (res % m)) % m) * (res % m) % m) % m);
  }
}
long long EGCD(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 0;
    y = 1;
    return a;
  } else {
    long long ans = EGCD(b, a % b, x, y);
    long long tmp = x;
    x = y - (a / b) * x;
    y = tmp;
    return ans;
  }
}
void sieve() {
  spf[1] = 1;
  for (int i = 2; i < 100001; i++) spf[i] = i;
  for (int i = 4; i < 100001; i += 2) spf[i] = 2;
  for (int i = 3; i * i < 100001; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < 100001; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
set<int> getFactorization(int x) {
  set<int> ret;
  while (x != 1) {
    ret.insert(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
string s, g;
long long memo[3005][3005];
long long solve(int idx, int idy) {
  if (s.size() == idx) {
    return g.size() - idy;
  } else if (g.size() == idy) {
    return s.size() - idx;
  }
  if (memo[idx][idy] != -1) {
    return memo[idx][idy];
  }
  if (s[idx] == g[idy]) {
    return memo[idx][idy] = solve(idx + 1, idy + 1);
  } else {
    return memo[idx][idy] =
               1 + min(solve(idx + 1, idy),
                       min(solve(idx, idy + 1), solve(idx + 1, idy + 1)));
  }
}
void build(int idx, int idy, int cnt) {
  if (idx == s.size()) {
    for (int i = idy; i < g.size(); ++i) {
      cout << "INSERT"
           << " " << idx + cnt << " " << g[i] << "\n";
      cnt += 1;
    }
    return;
  } else if (idy == g.size()) {
    for (int i = idx; i < s.size(); ++i) {
      cout << "DELETE"
           << " " << idx + cnt << "\n";
    }
    return;
  }
  if (s[idx] == g[idy]) {
    build(idx + 1, idy + 1, cnt);
  } else {
    if (solve(idx, idy + 1) + 1 == memo[idx][idy]) {
      cout << "INSERT"
           << " " << idx + cnt << " " << g[idy] << "\n";
      build(idx, idy + 1, cnt + 1);
    } else if (solve(idx + 1, idy + 1) + 1 == memo[idx][idy]) {
      cout << "REPLACE"
           << " " << idx + cnt << " " << g[idy] << "\n";
      build(idx + 1, idy + 1, cnt);
    } else {
      cout << "DELETE"
           << " " << idx + cnt << "\n";
      build(idx + 1, idy, cnt - 1);
    }
  }
}
int main() {
  cin >> s >> g;
  memset(memo, -1, sizeof(memo));
  cout << solve(0, 0) << "\n";
  build(0, 0, 1);
  return 0;
}

### Prompt

Create a solution in CPP for the following problem:

There is a string s, consisting of capital Latin letters. Let's denote its current length as |s|. During one move it is allowed to apply one of the following operations to it: 

  * INSERT pos ch — insert a letter ch in the string s in the position pos (1 ≤ pos ≤ |s| + 1, A ≤ ch ≤ Z). The letter ch becomes the pos-th symbol of the string s, at that the letters shift aside and the length of the string increases by 1. 
  * DELETE pos — delete a character number pos (1 ≤ pos ≤ |s|) from the string s. At that the letters shift together and the length of the string decreases by 1. 
  * REPLACE pos ch — the letter in the position pos of the line s is replaced by ch (1 ≤ pos ≤ |s|, A ≤ ch ≤ Z). At that the length of the string does not change. 



Your task is to find in which minimal number of moves one can get a t string from an s string. You should also find the sequence of actions leading to the required results.

Input

The first line contains s, the second line contains t. The lines consist only of capital Latin letters, their lengths are positive numbers from 1 to 1000.

Output

In the first line print the number of moves k in the given sequence of operations. The number should be the minimal possible one. Then print k lines containing one operation each. Print the operations in the format, described above. If there are several solutions, print any of them.

Examples

Input

ABA
ABBBA


Output

2
INSERT 3 B
INSERT 4 B


Input

ACCEPTED
WRONGANSWER


Output

10
REPLACE 1 W
REPLACE 2 R
REPLACE 3 O
REPLACE 4 N
REPLACE 5 G
REPLACE 6 A
INSERT 7 N
INSERT 8 S
INSERT 9 W
REPLACE 11 R

### Response

```cpp
#include <bits/stdc++.h>
long long mod = 1e9 + 7;
int spf[100001];
using namespace std;
void primeFactors(long long n, vector<long long> &vec) {
  while (n % 2 == 0) {
    vec.push_back(2);
    n = n / 2;
  }
  for (long long i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      vec.push_back(i);
      n = n / i;
    }
  }
  if (n > 2) {
    vec.push_back(n);
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
long long Lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }
tuple<long long, long long, long long> getL(complex<long double> p1,
                                            complex<long double> p2) {
  long long a, b, c;
  a = p2.imag() - p1.imag();
  b = p1.real() - p2.real();
  c = -a * p1.real() - b * p1.imag();
  long long gcdres = abs(gcd(a, gcd(b, c)));
  if (a < 0 || a == 0 && b < 0) {
    gcdres *= -1;
  }
  a /= gcdres;
  b /= gcdres;
  c /= gcdres;
  return tuple<long long, long long, long long>(a, b, c);
}
long long fastpow(long long base, long long pow) {
  if (!base) return 0;
  if (!pow) return 1;
  if (pow == 1) return base;
  long long x = fastpow(base, pow / 2) % mod;
  x *= x;
  x %= mod;
  if (pow % 2) x *= base;
  return x % mod;
}
long long inverse(long long x) { return fastpow(x, mod - 2) % mod; }
long double disty(pair<double, double> a, pair<double, double> b) {
  return sqrt(pow(b.second - a.second, 2.0) + pow(b.first - a.first, 2.0));
}
void factorize(long long x, set<long long> &ss) {
  while (x % 2 == 0) ss.insert(2), x /= 2;
  for (int i = 3; i <= sqrt(x); i += 2)
    while (x % i == 0) ss.insert(i), x /= i;
  if (x > 2) ss.insert(x);
}
void SieveOfEratosthenes(long long n, bool prime[]) {
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
void divisors(long long n, vector<long long> &vec) {
  for (long long i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0 && i != sqrt(n)) {
      vec.push_back(i);
      vec.push_back(n / i);
    } else if (n % i == 0) {
      vec.push_back(i);
    }
  }
}
bool isprime(long long n) {
  if (n == 1) {
    return false;
  }
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
complex<long double> rot(complex<long double> p, long double angle) {
  return (p * polar((long double)1.0, angle));
}
complex<long double> rotA(complex<long double> p, complex<long double> A,
                          long double angle) {
  return (((p - A) * polar((long double)1, angle)) + A);
}
long double distance(complex<long double> a, complex<long double> b) {
  long double x1 = a.real(), y1 = a.imag(), x2 = b.real(), y2 = b.imag();
  return pow(y2 - y1, 2) + pow(x2 - x1, 2);
}
int distSq(pair<long long, long long> p, pair<long long, long long> q) {
  return (p.first - q.first) * (p.first - q.first) +
         (p.second - q.second) * (p.second - q.second);
}
bool isSquare(pair<long long, long long> p1, pair<long long, long long> p2,
              pair<long long, long long> p3, pair<long long, long long> p4) {
  long long d2 = distSq(p1, p2);
  long long d3 = distSq(p1, p3);
  long long d4 = distSq(p1, p4);
  if (d2 == d3 && 2 * d2 == d4 && 2 * d2 == distSq(p2, p3)) {
    int d = distSq(p2, p4);
    return (d == distSq(p3, p4) && d == d2);
  }
  if (d3 == d4 && 2 * d3 == d2 && 2 * d3 == distSq(p3, p4)) {
    int d = distSq(p2, p3);
    return (d == distSq(p2, p4) && d == d3);
  }
  if (d2 == d4 && 2 * d2 == d3 && 2 * d2 == distSq(p2, p4)) {
    int d = distSq(p2, p3);
    return (d == distSq(p3, p4) && d == d2);
  }
  return false;
}
long long FP(long long base, long long power, long long m) {
  if (power == 0) {
    return 1;
  } else if (power % 2 == 0) {
    long long res = FP(base, power / 2, m);
    return (res % m * res % m) % m;
  } else {
    long long res = FP(base, power / 2, m);
    return ((((base % m * (res % m)) % m) * (res % m) % m) % m);
  }
}
long long EGCD(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 0;
    y = 1;
    return a;
  } else {
    long long ans = EGCD(b, a % b, x, y);
    long long tmp = x;
    x = y - (a / b) * x;
    y = tmp;
    return ans;
  }
}
void sieve() {
  spf[1] = 1;
  for (int i = 2; i < 100001; i++) spf[i] = i;
  for (int i = 4; i < 100001; i += 2) spf[i] = 2;
  for (int i = 3; i * i < 100001; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < 100001; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
set<int> getFactorization(int x) {
  set<int> ret;
  while (x != 1) {
    ret.insert(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
string s, g;
long long memo[3005][3005];
long long solve(int idx, int idy) {
  if (s.size() == idx) {
    return g.size() - idy;
  } else if (g.size() == idy) {
    return s.size() - idx;
  }
  if (memo[idx][idy] != -1) {
    return memo[idx][idy];
  }
  if (s[idx] == g[idy]) {
    return memo[idx][idy] = solve(idx + 1, idy + 1);
  } else {
    return memo[idx][idy] =
               1 + min(solve(idx + 1, idy),
                       min(solve(idx, idy + 1), solve(idx + 1, idy + 1)));
  }
}
void build(int idx, int idy, int cnt) {
  if (idx == s.size()) {
    for (int i = idy; i < g.size(); ++i) {
      cout << "INSERT"
           << " " << idx + cnt << " " << g[i] << "\n";
      cnt += 1;
    }
    return;
  } else if (idy == g.size()) {
    for (int i = idx; i < s.size(); ++i) {
      cout << "DELETE"
           << " " << idx + cnt << "\n";
    }
    return;
  }
  if (s[idx] == g[idy]) {
    build(idx + 1, idy + 1, cnt);
  } else {
    if (solve(idx, idy + 1) + 1 == memo[idx][idy]) {
      cout << "INSERT"
           << " " << idx + cnt << " " << g[idy] << "\n";
      build(idx, idy + 1, cnt + 1);
    } else if (solve(idx + 1, idy + 1) + 1 == memo[idx][idy]) {
      cout << "REPLACE"
           << " " << idx + cnt << " " << g[idy] << "\n";
      build(idx + 1, idy + 1, cnt);
    } else {
      cout << "DELETE"
           << " " << idx + cnt << "\n";
      build(idx + 1, idy, cnt - 1);
    }
  }
}
int main() {
  cin >> s >> g;
  memset(memo, -1, sizeof(memo));
  cout << solve(0, 0) << "\n";
  build(0, 0, 1);
  return 0;
}

```