#include<iostream>
#include<string>
using namespace std;
#define FOR(i , a , b) for(int i = a ; i < b; i++)
int dp[ 1001 ][ 1001 ];string s , t;
void print(int a ,int b){
    if(a>=0 || b>=0){
     if( a && b && dp[ a ][ b ] == dp[ a - 1 ][ b - 1 ] + 1 ) // rep
         cout << "REPLACE "<< a <<" "<<t[ b - 1 ]<<endl , print(a - 1 , b - 1);
     else
         if(b && dp[ a ][ b ] == dp[ a ][ b - 1 ] + 1) // ins
                cout << "INSERT "<< a + 1 <<" "<<t[ b - 1 ]<<endl , print(a , b - 1);
         else
             if(a && dp[ a ][ b ] == dp[ a - 1 ][ b ] + 1)// del
                 cout <<"DELETE "<< a <<endl , print(a - 1, b );
             else
                 print(a - 1 , b - 1);
    }
}
int main(){

    cin >> s >> t;
    FOR(i ,0 , s.size() + 1)
        dp[ i ][ 0 ] = i;
    FOR(j , 0 , t.size() + 1)
        dp[ 0 ][ j ] = j;
    FOR(i , 1 ,s.size() + 1)
        FOR(j , 1 , t.size() + 1)
           if(s[ i - 1 ] == t[ j - 1])
               dp[ i ][ j ] = dp[ i - 1 ][ j - 1 ];
           else
               dp[ i ][ j ] = min(dp[ i - 1 ][ j - 1 ],min(dp[ i ][ j - 1 ],dp[ i - 1 ][ j  ]) ) + 1;
    cout << dp[ s.size() ][ t.size() ] << endl;
    print( s.size() , t.size() );
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include<algorithm>
#include <cmath>
#include<sstream>
using namespace std;

string s,t;

int dp[1111][1111];

struct From{
    int x,y,op,pos;
    char a;
    void init(int aa,int b,int c,int e,char d){
        x=aa,y=b,op=c,a=d,pos=e;
    }
}from[1111][1111];

struct Op{
    int op,pos;
    char a;
}res[111111];
void zy(int x1,int y1,int x2,int y2,int op,int pos,char a){
    if(dp[x1][y1]==-1 || dp[x1][y1]>dp[x2][y2]+(op?1:0)){
        dp[x1][y1]=dp[x2][y2]+(op?1:0);
        from[x1][y1].init(x2,y2,op,pos,a);//cout<<x1<<" "<<y1<<" "<<a<<" "<<from[x1][y1].a<<endl;
    }
}
int main(){
    int i,j,k;
    while(cin>>s>>t){
        memset(dp,-1,sizeof(dp));
        memset(from,-1,sizeof(from));
        int ls=s.length(),lt=t.length();
        for(i=0;i<=lt;i++){
            dp[0][i]=i;
            if(i) from[0][i].init(0,i-1,1,i,t[i-1]);
            else from[0][i].init(-1,-1,0,i,'a');
        }
        for(i=0;i<=ls;i++){
            dp[i][0]=i;
            if(i) from[i][0].init(i-1,0,2,1,s[i-1]);
            else from[i][0].init(-1,-1,0,i,'a');
        }
        for(i=1;i<=ls;i++){
            for(j=1;j<=lt;j++){
                if(dp[i-1][j-1]!=-1){
                    if(s[i-1]==t[j-1]) zy(i,j,i-1,j-1,0,j,'a');
                    else zy(i,j,i-1,j-1,3,j,t[j-1]);
                }
                if(dp[i-1][j]!=-1) zy(i,j,i-1,j,2,j+1,s[i-1]);
                if(dp[i][j-1]!=-1) zy(i,j,i,j-1,1,j,t[j-1]);
            }
        }
        int x=ls,y=lt,num=0;
        while(x!=-1 && y!=-1){
            res[num].a=from[x][y].a;
            res[num].op=from[x][y].op;
            res[num++].pos=from[x][y].pos;
            int c=x;x=from[x][y].x,y=from[c][y].y;
        }
        for(i=num-1;i>=0;i--){
            if(!res[i].op){
                continue;
            }
            if(res[i].op==1){
                printf("INSERT %d %c\n",res[i].pos,res[i].a);
            }
            if(res[i].op==2) printf("DELETE %d\n",res[i].pos);
            if(res[i].op==3) printf("REPLACE %d %c\n",res[i].pos,res[i].a);
        }
    }
}


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include<algorithm>
#include <cmath>
#include<sstream>
using namespace std;

string s,t;

int dp[1111][1111];

struct From{
    int x,y,op,pos;
    char a;
    void init(int aa,int b,int c,int e,char d){
        x=aa,y=b,op=c,a=d,pos=e;
    }
}from[1111][1111];

struct Op{
    int op,pos;
    char a;
}res[111111];
void zy(int x1,int y1,int x2,int y2,int op,int pos,char a){
    if(dp[x1][y1]==-1 || dp[x1][y1]>dp[x2][y2]+(op?1:0)){
        dp[x1][y1]=dp[x2][y2]+(op?1:0);
        from[x1][y1].init(x2,y2,op,pos,a);//cout<<x1<<" "<<y1<<" "<<a<<" "<<from[x1][y1].a<<endl;
    }
}
int main(){
    int i,j,k;
    while(cin>>s>>t){
        memset(dp,-1,sizeof(dp));
        memset(from,-1,sizeof(from));
        int ls=s.length(),lt=t.length();
        for(i=0;i<=lt;i++){
            dp[0][i]=i;
            if(i) from[0][i].init(0,i-1,1,i,t[i-1]);
            else from[0][i].init(-1,-1,0,i,'a');
        }
        for(i=0;i<=ls;i++){
            dp[i][0]=i;
            if(i) from[i][0].init(i-1,0,2,1,s[i-1]);
            else from[i][0].init(-1,-1,0,i,'a');
        }
        for(i=1;i<=ls;i++){
            for(j=1;j<=lt;j++){
                if(dp[i-1][j-1]!=-1){
                    if(s[i-1]==t[j-1]) zy(i,j,i-1,j-1,0,j,'a');
                    else zy(i,j,i-1,j-1,3,j,t[j-1]);
                }
                if(dp[i-1][j]!=-1) zy(i,j,i-1,j,2,j+1,s[i-1]);
                if(dp[i][j-1]!=-1) zy(i,j,i,j-1,1,j,t[j-1]);
            }
        }
        int x=ls,y=lt,num=0;
        while(x!=-1 && y!=-1){
            res[num].a=from[x][y].a;
            res[num].op=from[x][y].op;
            res[num++].pos=from[x][y].pos;
            int c=x;x=from[x][y].x,y=from[c][y].y;
        }
        cout<<dp[ls][lt]<<endl;
        for(i=num-1;i>=0;i--){
            if(!res[i].op){
                continue;
            }
            if(res[i].op==1){
                printf("INSERT %d %c\n",res[i].pos,res[i].a);
            }
            if(res[i].op==2) printf("DELETE %d\n",res[i].pos);
            if(res[i].op==3) printf("REPLACE %d %c\n",res[i].pos,res[i].a);
        }
    }
}


#include<stdio.h>
#include<string.h>

#define maxm 1000

int dp[maxm][maxm];
int pre[maxm][maxm];

char s1[maxm],s2[maxm];

int cal(int i,int j);
void print(int i,int j);

int main(){

    int i,j,k,l,test,t=1;

 //   freopen("in.txt","r",stdin);

    scanf("%s",s1+1);
    scanf("%s",s2+1);

    k=strlen(s1+1); l=strlen(s2+1);

    memset(dp,-1,sizeof(dp));

    printf("%d\n",cal(k,l));
    print(k,l);

    return 0;
}

void print(int i,int j){

    if(i==0&&j==0) return ;

    if(s1[i]==s2[j]){
        print(i-1,j-1);
    }
    else if(pre[i][j]==2){
        printf("INSERT %d %c\n",i+1,s2[j]);
        print(i,j-1);
    }
    else if(pre[i][j]==1){
        printf("DELETE %d %c\n",i,s1[i]);
        print(i-1,j);
    }
    else{
        printf("REPLACE %d W\n",i,s2[j]);
        print(i-1,j-1);
    }
}

int cal(int i,int j){

    if(i==0&&j==0) return 0;
    if(i==0){
        pre[i][j]=2;
        return dp[i][j]=cal(i,j-1)+1;
    }
    if(j==0){
        pre[i][j]=1;
        return dp[i][j]=cal(i-1,j)+1;
    }

    if(s1[i]==s2[j]){
        pre[i][j]=0; return dp[i][j]=cal(i-1,j-1);
    }
    int ret=0,ret1;
    ret=cal(i-1,j)+1; pre[i][j]=1;

    ret1=cal(i,j-1)+1;
    if(ret1<ret){
        ret=ret1; pre[i][j]=2;
    }

    ret1=cal(i-1,j-1)+1;
    if(ret1<ret){
        ret=ret1; pre[i][j]=0;
    }

    return dp[i][j]=ret;

}


#include<stdio.h>
#include<string.h>

#define maxm 1000

int dp[maxm][maxm];
int pre[maxm][maxm];

char s1[maxm],s2[maxm];

int cal(int i,int j);
void print(int i,int j);

int main(){

    int i,j,k,l,test,t=1;

   // freopen("in.txt","r",stdin);

    scanf("%s",s1+1);
    scanf("%s",s2+1);

    k=strlen(s1+1); l=strlen(s2+1);

    memset(dp,-1,sizeof(dp));

    printf("%d\n",cal(k,l));
    print(k,l);

    return 0;
}

void print(int i,int j){

    if(i==0&&j==0) return ;

    if(s1[i]==s2[j]){
        print(i-1,j-1);
    }
    else if(pre[i][j]==2){
        printf("INSERT %d %c\n",i+1,s2[j]);
        print(i,j-1);
    }
    else if(pre[i][j]==1){
        printf("DELETE %d %c\n",i,s1[i]);
        print(i-1,j);
    }
    else{
        printf("REPLACE %d %c\n",i,s2[j]);
        print(i-1,j-1);
    }
}

int cal(int i,int j){

    if(i==0&&j==0) return 0;
    if(i==0){
        pre[i][j]=2;
        return dp[i][j]=cal(i,j-1)+1;
    }
    if(j==0){
        pre[i][j]=1;
        return dp[i][j]=cal(i-1,j)+1;
    }

    if(s1[i]==s2[j]){
        pre[i][j]=0; return dp[i][j]=cal(i-1,j-1);
    }
    int ret=0,ret1;
    ret=cal(i-1,j)+1; pre[i][j]=1;

    ret1=cal(i,j-1)+1;
    if(ret1<ret){
        ret=ret1; pre[i][j]=2;
    }

    ret1=cal(i-1,j-1)+1;
    if(ret1<ret){
        ret=ret1; pre[i][j]=0;
    }

    return dp[i][j]=ret;

}


#include<stdio.h>
#include<string.h>

#define maxm 1100

int dp[maxm][maxm];
int pre[maxm][maxm];

char s1[maxm],s2[maxm];

int cal(int i,int j);
void print(int i,int j);

int main(){

    int i,j,k,l,test,t=1;

   // freopen("in.txt","r",stdin);

    scanf("%s",s1+1);
    scanf("%s",s2+1);

    k=strlen(s1+1); l=strlen(s2+1);

    memset(dp,-1,sizeof(dp));

    printf("%d\n",cal(k,l));
    print(k,l);

    return 0;
}

void print(int i,int j){

    if(i==0&&j==0) return ;

    if(s1[i]==s2[j]){
        print(i-1,j-1);
    }
    else if(pre[i][j]==2){
        printf("INSERT %d %c\n",i+1,s2[j]);
        print(i,j-1);
    }
    else if(pre[i][j]==1){
        printf("DELETE %d\n",i);
        print(i-1,j);
    }
    else{
        printf("REPLACE %d %c\n",i,s2[j]);
        print(i-1,j-1);
    }
}

int cal(int i,int j){

    if(i==0&&j==0) return 0;

    if(dp[i][j]!=-1) return dp[i][j];

    if(i==0){
        pre[i][j]=2;
        return dp[i][j]=cal(i,j-1)+1;
    }
    if(j==0){
        pre[i][j]=1;
        return dp[i][j]=cal(i-1,j)+1;
    }

    if(s1[i]==s2[j]){
        pre[i][j]=0; return dp[i][j]=cal(i-1,j-1);
    }
    int ret=0,ret1;
    ret=cal(i-1,j)+1; pre[i][j]=1;

    ret1=cal(i,j-1)+1;
    if(ret1<ret){
        ret=ret1; pre[i][j]=2;
    }

    ret1=cal(i-1,j-1)+1;
    if(ret1<ret){
        ret=ret1; pre[i][j]=0;
    }

    return dp[i][j]=ret;

}


#include<stdio.h>
#include<string.h>

#define maxm 1000

int dp[maxm][maxm];
int pre[maxm][maxm];

char s1[maxm],s2[maxm];

int cal(int i,int j);
void print(int i,int j);

int main(){

    int i,j,k,l,test,t=1;

   // freopen("in.txt","r",stdin);

    scanf("%s",s1+1);
    scanf("%s",s2+1);

    k=strlen(s1+1); l=strlen(s2+1);

    memset(dp,-1,sizeof(dp));

    printf("%d\n",cal(k,l));
    print(k,l);

    return 0;
}

void print(int i,int j){

    if(i==0&&j==0) return ;

    if(s1[i]==s2[j]){
        print(i-1,j-1);
    }
    else if(pre[i][j]==2){
        printf("INSERT %d %c\n",i+1,s2[j]);
        print(i,j-1);
    }
    else if(pre[i][j]==1){
        printf("DELETE %d\n",i);
        print(i-1,j);
    }
    else{
        printf("REPLACE %d %c\n",i,s2[j]);
        print(i-1,j-1);
    }
}

int cal(int i,int j){

    if(i==0&&j==0) return 0;
    if(i==0){
        pre[i][j]=2;
        return dp[i][j]=cal(i,j-1)+1;
    }
    if(j==0){
        pre[i][j]=1;
        return dp[i][j]=cal(i-1,j)+1;
    }

    if(s1[i]==s2[j]){
        pre[i][j]=0; return dp[i][j]=cal(i-1,j-1);
    }
    int ret=0,ret1;
    ret=cal(i-1,j)+1; pre[i][j]=1;

    ret1=cal(i,j-1)+1;
    if(ret1<ret){
        ret=ret1; pre[i][j]=2;
    }

    ret1=cal(i-1,j-1)+1;
    if(ret1<ret){
        ret=ret1; pre[i][j]=0;
    }

    return dp[i][j]=ret;

}


#include<stdio.h>
#include<string.h>

#define maxm 1000

int dp[maxm][maxm];
int pre[maxm][maxm];

char s1[maxm],s2[maxm];

int cal(int i,int j);
void print(int i,int j);

int main(){

    int i,j,k,l,test,t=1;

   // freopen("in.txt","r",stdin);

    scanf("%s",s1+1);
    scanf("%s",s2+1);

    k=strlen(s1+1); l=strlen(s2+1);

    memset(dp,-1,sizeof(dp));

    printf("%d\n",cal(k,l));
    print(k,l);

    return 0;
}

void print(int i,int j){

    if(i==0&&j==0) return ;

    if(s1[i]==s2[j]){
        print(i-1,j-1);
    }
    else if(pre[i][j]==2){
        printf("INSERT %d %c\n",i+1,s2[j]);
        print(i,j-1);
    }
    else if(pre[i][j]==1){
        printf("DELETE %d\n",i);
        print(i-1,j);
    }
    else{
        printf("REPLACE %d %c\n",i,s2[j]);
        print(i-1,j-1);
    }
}

int cal(int i,int j){

    if(i==0&&j==0) return 0;

    if(dp[i][j]!=-1) return dp[i][j];

    if(i==0){
        pre[i][j]=2;
        return dp[i][j]=cal(i,j-1)+1;
    }
    if(j==0){
        pre[i][j]=1;
        return dp[i][j]=cal(i-1,j)+1;
    }

    if(s1[i]==s2[j]){
        pre[i][j]=0; return dp[i][j]=cal(i-1,j-1);
    }
    int ret=0,ret1;
    ret=cal(i-1,j)+1; pre[i][j]=1;

    ret1=cal(i,j-1)+1;
    if(ret1<ret){
        ret=ret1; pre[i][j]=2;
    }

    ret1=cal(i-1,j-1)+1;
    if(ret1<ret){
        ret=ret1; pre[i][j]=0;
    }

    return dp[i][j]=ret;

}


#define _HAS_CPP0X 0
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:16777216")
#include <queue>
#include <cassert>
#include <sstream>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <iostream>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
#define FOR(i, n) for(int i = 0; i < (int)(n); ++i)

string sa, sb;

enum Op
{
	nop,
	rep,
	ins,
	del
};
struct Res
{
	Op op;
	int len;
	Res(int len = 3000) : len(len) { }
	friend bool operator < (const Res& a, const Res& b)
	{
		return a.len < b.len || a.len == b.len && a.op < b.op;
	}
};
map<PII, Res> mem;
const Res& Get(int a, int b)
{
	static Res inf;
	if (a < 0 || b < 0)
		return inf;
	int sz = mem.size();
	Res& res = mem[PII(a, b)];
	if (sz != mem.size())
	{
		if (a == 0 && b == 0)
		{
			res.len = 0;
			res.op = nop;
		}
		else
		{
			Res nr;
			if (a > 0 && b > 0)
			{
				nr = Get(a - 1, b - 1);
				if (sa[a - 1] == sb[b - 1])
				{
					nr.op = nop;
				}
				else
				{
					nr.len++;
					nr.op = rep;
				}
				if (nr < res)
					res = nr;
			}
			if (a > 0)
			{
				nr.len = Get(a - 1, b).len + 1;
				nr.op = del;
				if (nr < res)
					res = nr;
			}
			if (b > 0)
			{
				nr.len = Get(a, b - 1).len + 1;
				nr.op = ins;
				if (nr < res)
					res = nr;
			}
		}
	}
	return res;
}

int main()
{
#ifdef _DEBUG
	freopen("inp.txt", "r", stdin);
#endif
	cin >> sa >> sb;
	Res r = Get(sa.size(), sb.size());
	int a = sa.size();
	int b = sb.size();
	vector<string> res;
	while (a != 0 || b != 0)
	{
		stringstream ss;
		const Res& r = Get(a, b);
		if (r.op == nop)
			a--, b--;
		else if (r.op == rep)
		{
			ss << "REPLACE" << ' ' << b << ' ' << sb[b - 1];
			a--, b--;
		}
		else if (r.op == ins)
		{
			ss << "INSERT" << ' ' << b << ' ' << sb[b - 1];
			b--;
		}
		else
		{
			ss << "DELETE" << ' ' << a;
			a--;
		}
		if (ss.str().size() != 0)
			res.push_back(ss.str());
	}
	reverse(res.begin(), res.end());
	cout << res.size() << endl;
	FOR(i, res.size())
		cout << res[i] << endl;
	return 0;
}


#define _HAS_CPP0X 0
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:16777216")
#include <queue>
#include <cassert>
#include <sstream>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <iostream>
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
#define FOR(i, n) for(int i = 0; i < (int)(n); ++i)

string sa, sb;

enum Op
{
	nop,
	rep,
	ins,
	del
};
struct Res
{
	Op op;
	int len;
	int lena;
	Res(int len = 3000) : len(len) { }
	friend bool operator < (const Res& a, const Res& b)
	{
		return a.len < b.len || a.len == b.len && a.op < b.op;
	}
};
map<PII, Res> mem;
const Res& Get(int a, int b)
{
	int sz = mem.size();
	Res& res = mem[PII(a, b)];
	if (sz != mem.size())
	{
		if (a == 0 && b == 0)
		{
			res.len = 0;
			res.op = nop;
			res.lena = 0;
		}
		else
		{
			Res nr;
			if (a > 0 && b > 0)
			{
				nr = Get(a - 1, b - 1);
				if (sa[a - 1] == sb[b - 1])
				{
					nr.op = nop;
				}
				else
				{
					nr.len++;
					nr.op = rep;
				}
				nr.lena++;
				if (nr < res)
					res = nr;
			}
			if (a > 0)
			{
				nr = Get(a - 1, b);
				nr.len++;
				nr.op = del;
				if (nr < res)
					res = nr;
			}
			if (b > 0)
			{
				nr = Get(a, b - 1);
				nr.len++;
				nr.lena++;
				nr.op = ins;
				if (nr < res)
					res = nr;
			}
		}
	}
	return res;
}

int main()
{
#ifdef _DEBUG
	freopen("inp.txt", "r", stdin);
#endif
	cin >> sa >> sb;
	Res r = Get(sa.size(), sb.size());
	int a = sa.size();
	int b = sb.size();
	vector<string> res;
	while (a != 0 || b != 0)
	{
		stringstream ss;
		const Res& r = Get(a, b);
		if (r.op == nop)
			a--, b--;
		else if (r.op == rep)
		{
			ss << "REPLACE" << ' ' << r.lena << ' ' << sb[b - 1];
			a--, b--;
		}
		else if (r.op == ins)
		{
			ss << "INSERT" << ' ' << r.lena << ' ' << sb[b - 1];
			b--;
		}
		else
		{
			ss << "DELETE" << ' ' << r.lena + 1;
			a--;
		}
		if (ss.str().size() != 0)
			res.push_back(ss.str());
	}
	reverse(res.begin(), res.end());
	cout << res.size() << endl;
	FOR(i, res.size())
		cout << res[i] << endl;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

const int inf = 1000*1000*1000;
#define CL(x,a) memset(x,a,sizeof(x));
#define ALL(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define PDI pair<double,int>
#define MP(a,b) make_pair(a,b)
#define FOR(i,n) for(int i=0;i<n;i++)
typedef long long LL;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vector<PII > > vvpii;

char s1[1024],s2[1024];
char b1[1024],b2[1024];
int dp[1024][1024];
int w[1024][1024],L1,L2;/*
int DP(int a, int b)
{
	if (a == 0 || b == 0)
		return 0;
	if (dp[a][b] != -1)
		return dp[a][b];
	w[a][b]=0;
	int res = DP(a-1,b);
	if (res < DP(a,b-1))
	{
		res = DP(a,b-1);
		w[a][b]=1;
	}
	if (s1[a]==s2[a])
		if (res < DP(a-1,b-1)+1))
		{
			res = DP(a-1,b-1)+1);
			w[a][b]=2;
		}
	dp[a][b]=res;
	return res;
}
int way(int a, int b)
{
	if (w[a][b] == -1)
		return;
	if (w[a][b] == 0)
	{
		way(a-1,b);
	}
	if (w[a][b] == 1)
	{
		way(a,b-1);
	}
	if (w[a][b] == 2)
	{
		b1[a]=1;
		b2[b]=1;
		way(a-1,b-1);
	}
}*/
int DP(int a, int b)
{
	if (a == L1 && b == L2)
		return 0;
	if (dp[a][b] != -1)
		return dp[a][b];
	int res = inf;
	if (a < L1 && b < L2 && s1[a] == s2[b])
	{
		w[a][b]=0;
		res = min(res,DP(a+1,b+1));
	}
	else if (a < L1 && b == L2)
	{
		if (res>DP(a+1,b)+1)
		{
			w[a][b]=1;
			res = DP(a+1,b)+1;
		}// ADD
	}
	else if (a < L1 && b < L2)
	{
		if (res>DP(a+1,b+1)+1)
		{
			w[a][b]=2;
			res=DP(a+1,b+1)+1;
		}//replace
		if (res>DP(a+1,b)+1)
		{
			w[a][b]=1;
			res=DP(a+1,b)+1;
		}//ADD
		if (res>DP(a,b+1)+1)
		{
			w[a][b]=3;
			res=DP(a,b+1)+1;
		}//REMOVE
	}
	else if (a == L1 && b < L2)
	{
		if (res>DP(a,b+1)+1)
		{
			w[a][b]=3;
			res=DP(a,b+1)+1;
		}//REMOVE
	}
	dp[a][b] = res;
	return res;
}
void way(int a, int b, int pos)
{
	if (w[a][b] == -1)
		return;
	if (w[a][b] == 0)
	{
		way(a+1,b+1,pos+1);
	}
	if (w[a][b] == 1)
	{
		printf("INSERT %d %c\n",pos+1,s1[a]);
		way(a+1,b,pos+1);
	}
	if (w[a][b] == 2)
	{
		printf("REPLACE %d %c\n",pos+1,s1[a]);
		way(a+1,b+1,pos+1);
	}
	if (w[a][b] == 3)
	{
		printf("DELETE %d\n",pos+1);
		way(a,b+1,pos);
	}
}
int main()
{
	CL(w,-1);
	CL(dp,-1);
	gets(s2);
	gets(s1);
	L1=strlen(s1);
	L2=strlen(s2);
	printf("%d\n",DP(0,0));
	way(0,0,0);
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;

#define file "file"
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;

const int MAXN = 1e3+5;
const double EPS = 1e-9;
const ll m = 1000000007 ;

char s[MAXN];
char t[MAXN];

int dp[MAXN][MAXN];
int p[MAXN][MAXN];
//1-insert,2-delete,3-replace,0-none

int main()
{
	//freopen(file ".in","r",stdin);freopen(file ".out","w",stdout);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	scanf("%s\n",s);
	scanf("%s",t);
	int n1 = strlen(s);
	int n2 = strlen(t);

	for(int i=0;i<n1;i++)
		for(int j=0;j<n2;j++)
		{
			dp[i][j] = MAXN;
		}

	if(s[n1-1]==t[n2-1])
	{
		dp[n1-1][n2-1] = 0;
		p[n1-1][n2-1] = 0;
	}
	else
	{
		dp[n1-1][n2-1] = 1;
		p[n1-1][n2-1] = 3;
	}
	for(int i=n1-1;i>=0;i--)
	{
		for(int j=n2-1;j>=0;j--)
		{
			if(i+1<n1 && j+1<n2)
			{
				if(s[i]==t[j])
				{
					if(dp[i][j]>dp[i+1][j+1])
					{
						dp[i][j] = dp[i+1][j+1];
						p[i][j] = 0;

					}
				}
				else
				{
					if(dp[i][j]>dp[i+1][j+1]+1)
					{
						dp[i][j] = dp[i+1][j+1]+1;
						p[i][j] = 3;
					}
				}
			}//if(i+1<n1 && j+1<n2)

			if(i+1<n1)
			{
				if(dp[i][j]>dp[i+1][j]+1)
				{
					dp[i][j] = dp[i+1][j]+1;
					p[i][j] = 2;
				}
			}

			if(j+1<n2)
			{
				if(dp[i][j]>dp[i][j+1]+1)
				{
					dp[i][j] = dp[i][j+1]+1;
					p[i][j] = 1;
				}
			}
		}
	}

	int ans = dp[0][0];
	printf("%d\n",ans);

	int p1 = 0,p2 = 0;
	int d = 0;
	while(p1<n1 || p2<n2)
	{
		if(p[p1][p2]==0)
		{
			p1++;
			p2++;
		}
		else
		{
			if(p[p1][p2]==1)
			{
				printf("INSERT %d %1c\n",p1+1+d,t[p2]);
				p2++;
				d++;
			}
			else
			{
				if(p[p1][p2]==2)
				{
					printf("DELETE %d %1c\n",p1+1+d,s[p1]);
					p1++;
					d--;
				}
				else
				{
					printf("REPLACE %d %1c\n",p1+1+d,t[p2]);
					p1++;
					p2++;
				}
			}
		}
	}
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;

#define file "file"
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;

const int MAXN = 1e3+5;
const double EPS = 1e-9;
const ll m = 1000000007 ;

char s[MAXN];
char t[MAXN];

int dp[MAXN][MAXN];
int p[MAXN][MAXN];
//1-insert,2-delete,3-replace,0-none

int main()
{
	//freopen(file ".in","r",stdin);freopen(file ".out","w",stdout);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	scanf("%s\n",s);
	scanf("%s",t);
	int n1 = strlen(s);
	int n2 = strlen(t);

	for(int i=0;i<=n1;i++)
		for(int j=0;j<=n2;j++)
		{
			dp[i][j] = MAXN;
		}
	dp[n1][n2] = 0;
	s[n1] = '!';
	t[n2] = '!';

	for(int i=n1;i>=0;i--)
	{
		for(int j=n2;j>=0;j--)
		{
			if(i+1<=n1 && j+1<=n2)
			{
				if(s[i]==t[j])
				{
					if(dp[i][j]>dp[i+1][j+1])
					{
						dp[i][j] = dp[i+1][j+1];
						p[i][j] = 0;
					}
				}
				else
				{
					if(dp[i][j]>dp[i+1][j+1]+1)
					{
						dp[i][j] = dp[i+1][j+1]+1;
						p[i][j] = 3;
					}
				}
			}//if(i+1<n1 && j+1<n2)

			if(i+1<=n1 && j+1<=n2)
			{
				if(dp[i][j]>dp[i+1][j+1]+1)
				{
					dp[i][j] = dp[i+1][j+1]+1;
					p[i][j] = 3;
				}
			}

			if(i+1<=n1)
			{
				if(dp[i][j]>dp[i+1][j]+1)
				{
					dp[i][j] = dp[i+1][j]+1;
					p[i][j] = 2;
				}
			}

			if(j+1<=n2)
			{
				if(dp[i][j]>dp[i][j+1]+1)
				{
					dp[i][j] = dp[i][j+1]+1;
					p[i][j] = 1;
				}
			}
		}
	}

	int ans = dp[0][0];
	printf("%d\n",ans);

	int p1 = 0,p2 = 0;
	int d = 0;
	while(p1<n1 || p2<n2)
	{
		if(p[p1][p2]==0)
		{
			p1++;
			p2++;
		}
		else
		{
			if(p[p1][p2]==1)
			{
				printf("INSERT %d %1c\n",p1+1+d,t[p2]);
				p2++;
				d++;
			}
			else
			{
				if(p[p1][p2]==2)
				{
					printf("DELETE %d\n",p1+1+d);
					p1++;
					d--;
				}
				else
				{
					printf("REPLACE %d %1c\n",p1+1+d,t[p2]);
					p1++;
					p2++;
				}
			}
		}
	}
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;

#define file "file"
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;

const int MAXN = 1e3+5;
const double EPS = 1e-9;
const ll m = 1000000007 ;

char s[MAXN];
char t[MAXN];

int dp[MAXN][MAXN];
int p[MAXN][MAXN];
//1-insert,2-delete,3-replace,0-none

int main()
{
	//freopen(file ".in","r",stdin);freopen(file ".out","w",stdout);
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	scanf("%s\n",s);
	scanf("%s",t);
	int n1 = strlen(s);
	int n2 = strlen(t);

	for(int i=0;i<n1;i++)
		for(int j=0;j<n2;j++)
		{
			dp[i][j] = MAXN;
		}

	if(s[n1-1]==t[n2-1])
	{
		dp[n1-1][n2-1] = 0;
		p[n1-1][n2-1] = 0;
	}
	else
	{
		dp[n1-1][n2-1] = 1;
		p[n1-1][n2-1] = 3;
	}
	for(int i=n1-1;i>=0;i--)
	{
		for(int j=n2-1;j>=0;j--)
		{
			if(i+1<n1 && j+1<n2)
			{
				if(s[i]==t[j])
				{
					if(dp[i][j]>dp[i+1][j+1])
					{
						dp[i][j] = dp[i+1][j+1];
						p[i][j] = 0;

					}
				}
				else
				{
					if(dp[i][j]>dp[i+1][j+1]+1)
					{
						dp[i][j] = dp[i+1][j+1]+1;
						p[i][j] = 3;
					}
				}
			}//if(i+1<n1 && j+1<n2)

			if(i+1<n1)
			{
				if(dp[i][j]>dp[i+1][j]+1)
				{
					dp[i][j] = dp[i+1][j]+1;
					p[i][j] = 2;
				}
			}

			if(j+1<n2)
			{
				if(dp[i][j]>dp[i][j+1]+1)
				{
					dp[i][j] = dp[i][j+1]+1;
					p[i][j] = 1;
				}
			}
		}
	}

	int ans = dp[0][0];
	printf("%d\n",ans);

	int p1 = 0,p2 = 0;
	int d = 0;
	while(p1<n1 || p2<n2)
	{
		if(p[p1][p2]==0)
		{
			p1++;
			p2++;
		}
		else
		{
			if(p[p1][p2]==1)
			{
				printf("INSERT %d %1c\n",p1+1+d,t[p2]);
				p2++;
				d++;
			}
			else
			{
				if(p[p1][p2]==2)
				{
					printf("DELETE %d\n",p1+1+d);
					p1++;
					d--;
				}
				else
				{
					printf("REPLACE %d %1c\n",p1+1+d,t[p2]);
					p1++;
					p2++;
				}
			}
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:64000000")

#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <utility>

#include <set>
#include <map>
#include <vector>
#include <string>
#include <queue>

#include <iostream>
#include <sstream>

using namespace std;

typedef long long int64;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()

const int INF = (int)1E9;
const int64 INF64 = (int64)1E18;
const long double EPS = 1E-8;
const long double PI = 3.1415926535897932384626433832795;

string s, t;
int d[1100][1100];
pair<int, int> next[1100][1100];

int solve(int v1, int v2) {
    if (v1 == (int)s.size() && v2 == (int)t.size()) return 0;

    int &ans = d[v1][v2];
    if (ans != -1) return ans;

    ans = INF;

    {
        int value = INF;
        if (v1 < (int)s.size() && v2 < (int)t.size() && s[v1] == t[v2])
            value = solve(v1 + 1, v2 + 1);

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1 + 1, v2 + 1);
        }
    }

    {
        int value = INF;
        if (v1 < (int)s.size() && v2 < (int)t.size())
            value = solve(v1 + 1, v2 + 1) + 1;

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1 + 1, v2 + 1);
        }
    }

    {
        int value = INF;
        if (v1 < (int)s.size())
            value = solve(v1 + 1, v2) + 1;

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1 + 1, v2);
        }
    }

    {
        int value = INF;
        if (v2 < (int)t.size())
            value = solve(v1, v2 + 1) + 1;

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1, v2 + 1);
        }
    }

    return ans;
}

void getAnswer(int v1, int v2, int real) {
    if (v1 == (int)s.size() && v2 == (int)t.size()) return;

    int nl = next[v1][v2].first, nr = next[v1][v2].second;

    if (nl == v1 + 1 && nr == v2 + 1 && s[v1] != t[v2]) {
        cout << "REPLACE " << real << " " << t[v2] << endl;
        real++;
    }

    if (nl == v1 + 1 && nr == v2 + 1 && s[v1] == t[v2]) real++;

    if (nl == v1 + 1 && nr == v2)
        cout << "DELETE " << real << endl;

    if (nl == v1 && nr == v2 + 1) {
        cout << "INSERT " << real << " " << t[v2] << endl;
        real++;
    }

    getAnswer(nl, nr, real);
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif

    cin >> s >> t;

    memset(d, 255, sizeof d);
    cout << solve(0, 0) << endl;
    getAnswer(0, 0, 1);

    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:64000000")

#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <utility>

#include <set>
#include <map>
#include <vector>
#include <string>
#include <queue>

#include <iostream>
#include <sstream>

using namespace std;

typedef long long int64;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()

const int INF = (int)1E9;
const int64 INF64 = (int64)1E18;
const long double EPS = 1E-8;
const long double PI = 3.1415926535897932384626433832795;

string s, t;
int d[1100][1100];
pair<int, int> next[1100][1100];

int solve(int v1, int v2) {
    if (v1 == (int)s.size() && v2 == (int)t.size()) return 0;

    int &ans = d[v1][v2];
    if (ans != -1) return ans;

    ans = INF;

    {
        int value = INF;
        if (v1 < (int)s.size() && v2 < (int)t.size() && s[v1] == t[v2])
            value = solve(v1 + 1, v2 + 1);

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1 + 1, v2 + 1);
        }
    }

    {
        int value = INF;
        if (v1 < (int)s.size() && v2 < (int)t.size())
            value = solve(v1 + 1, v2 + 1) + 1;

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1 + 1, v2 + 1);
        }
    }

    {
        int value = INF;
        if (v1 < (int)s.size())
            value = solve(v1 + 1, v2) + 1;

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1 + 1, v2);
        }
    }

    {
        int value = INF;
        if (v2 < (int)t.size())
            value = solve(v1, v2 + 1) + 1;

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1, v2 + 1);
        }
    }

    return ans;
}

void getAnswer(int v1, int v2, int real) {
    if (v1 == (int)s.size() && v2 == (int)t.size()) return;

    int nl = next[v1][v2].first, nr = next[v1][v2].second;

    if (nl == v1 + 1 && nr == v2 + 1 && s[v1] != t[v2]) {
        cout << "REPLACE " << real << " " << t[v2] << endl;
        real++;
    }

    if (nl == v1 + 1 && nr == v2)
        cout << "DELETE " << real << endl;

    if (nl == v1 && nr == v2 + 1) {
        cout << "INSERT " << real << " " << t[v2] << endl;
        real++;
    }

    getAnswer(nl, nr, real);
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif

    cin >> s >> t;

    memset(d, 255, sizeof d);
    cout << solve(0, 0) << endl;
    getAnswer(0, 0, 1);

    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:64000000")

#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <utility>

#include <set>
#include <map>
#include <vector>
#include <string>
#include <queue>

#include <iostream>
#include <sstream>

using namespace std;

typedef long long int64;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()

const int INF = (int)1E9;
const int64 INF64 = (int64)1E18;
const long double EPS = 1E-8;
const long double PI = 3.1415926535897932384626433832795;

string s, t;
int d[1100][1100];
pair<int, int> next[1100][1100];

int solve(int v1, int v2) {
    if (v1 == (int)s.size() && v2 == (int)t.size()) return 0;

    int &ans = d[v1][v2];
    if (ans != -1) return ans;

    ans = INF;

    {
        int value = INF;
        if (v1 < (int)s.size() && v2 < (int)t.size() && s[v1] == t[v2])
            value = solve(v1 + 1, v2 + 1);

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1 + 1, v2 + 1);
        }
    }

    {
        int value = INF;
        if (v1 < (int)s.size() && v2 < (int)t.size())
            value = solve(v1 + 1, v2 + 1) + 1;

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1 + 1, v2 + 1);
        }
    }

    {
        int value = INF;
        if (v1 < (int)s.size())
            value = solve(v1 + 1, v2) + 1;

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1 + 1, v2);
        }
    }

    {
        int value = INF;
        if (v2 < (int)t.size())
            value = solve(v1, v2 + 1) + 1;

        if (ans > value) {
            ans = value;
            next[v1][v2] = mp(v1, v2 + 1);
        }
    }

    return ans;
}

void getAnswer(int v1, int v2) {
    if (v1 == (int)s.size() && v2 == (int)t.size()) return;

    int nl = next[v1][v2].first, nr = next[v1][v2].second;

    if (nl == v1 + 1 && nr == v2 + 1 && s[v1] != t[v2])
        cout << "REPLACE " << v1 + 1 << " " << t[v2] << endl;

    if (nl == v1 + 1 && nr == v2)
        cout << "DELETE " << v1 + 1 << endl;

    if (nl == v1 && nr == v2 + 1)
        cout << "INSERT " << v1 + 1 << " " << t[v2] << endl;

    getAnswer(nl, nr);
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif

    cin >> s >> t;

    memset(d, 255, sizeof d);
    cout << solve(0, 0) << endl;
    getAnswer(0, 0);

    return 0;
}


#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <utility>

using namespace std;

const int M=1000+5;

int F[M][M];

struct NODE{
	string ope;
	int index;
	char letter;
}node[M];

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	string s,t;
	cin>>s>>t;

	for (int col=1; col<=t.length(); col++)
	{
		F[0][col]=col;
	}
	for (int row=1; row<=s.length(); row++)
	{
		F[row][0]=row;
	}

	for (int row=1; row<=s.length(); row++)
	{
		for (int col=1; col<=t.length(); col++)
		{
			int tmp=F[row-1][col]+1;
			F[row][col]=tmp;
			if (F[row][col-1]+1<F[row][col])
			{
				F[row][col]=F[row][col-1]+1;
			}
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]<F[row][col])
				{
					F[row][col]=F[row-1][col-1];
				}
			}
			else
			{
				if (F[row-1][col-1]+1<F[row][col])
				{
					F[row][col]=F[row-1][col-1]+1;
				}
			}
		}
	}

	cout<<F[s.length()][t.length()]<<endl;

	int row=s.length();
	int col=t.length();
	int ans=0;
	while (row>=0 && col>=0)
	{
		int min_v=1E+9;
		int irow=-1;
		int icol=-1;
		bool updated=false;
		if (col-1>=0 && row-1>=0)
		{
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]<min_v)
				{
					min_v=F[row-1][col-1];
					irow=row-1;
					icol=col-1;
				}
			}
			else
			{
				if (F[row-1][col-1]+1<min_v)
				{
					min_v=F[row-1][col-1]+1;
					node[ans].ope="REPLACE";
					node[ans].index=col;
					node[ans].letter=t[col-1];
					irow=row-1;
					icol=col-1;
					updated=true;
				}
			}
		}
		if (row-1>=0 && col>=0)
		{
			if (F[row-1][col]+1<min_v)
			{
				min_v=F[row-1][col]+1;
				node[ans].ope="DELETE";
				node[ans].index=row;
				node[ans].letter=s[row-1];
				irow=row-1;
				icol=col;
				updated=true;
			}
		}
		if (row>=0 && col-1>=0)
		{
			if (F[row][col-1]+1<min_v)
			{
				min_v=F[row][col-1]+1;
				node[ans].ope="INSERT";
				node[ans].index=col;
				node[ans].letter=t[col-1];
				irow=row;
				icol=col-1;
				updated=true;
			}
		}
		if (updated==true)
		{
			ans++;
		}
		row=irow;
		col=icol;

	}

	for (int i=ans-1; i>=0; i--)
	{
		cout<<node[i].ope<<" "<<node[i].index<<" "<<node[i].letter<<endl;
	}

	return 0;

}


#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <cstdio>
#include <cstring>
#include <utility>

using namespace std;

const int M=1000+5;

int F[M][M];

struct NODE{
	string ope;
	int index;
	char letter;
}node[M];

char a[M];
char b[M];

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	string s;
	string t;
	//cin>>s>>t;
	getline(cin,s);
	getline(cin,s);

	for (int col=1; col<=t.length(); col++)
	{
		F[0][col]=col;
	}
	for (int row=1; row<=s.length(); row++)
	{
		F[row][0]=row;
	}

	for (int row=1; row<=s.length(); row++)
	{
		for (int col=1; col<=t.length(); col++)
		{
			int tmp=F[row-1][col]+1;
			F[row][col]=tmp;
			if (F[row][col-1]+1<F[row][col])
			{
				F[row][col]=F[row][col-1]+1;
			}
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]<F[row][col])
				{
					F[row][col]=F[row-1][col-1];
				}
			}
			else
			{
				if (F[row-1][col-1]+1<F[row][col])
				{
					F[row][col]=F[row-1][col-1]+1;
				}
			}
		}
	}

	cout<<F[s.length()][t.length()]<<endl;

	int row=s.length();
	int col=t.length();
	int ans=0;
	while (row>=0 && col>=0)
	{
		int min_v=1E+9;
		int irow=-1;
		int icol=-1;
		bool updated=false;
		if (col-1>=0 && row-1>=0)
		{
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]<min_v)
				{
					min_v=F[row-1][col-1];
					irow=row-1;
					icol=col-1;
				}
			}
			else
			{
				if (F[row-1][col-1]+1<min_v)
				{
					min_v=F[row-1][col-1]+1;
					node[ans].ope="REPLACE";
					node[ans].index=col;
					node[ans].letter=t[col-1];
					irow=row-1;
					icol=col-1;
					updated=true;
				}
			}
		}
		if (row-1>=0 && col>=0)
		{
			if (F[row-1][col]+1<min_v)
			{
				min_v=F[row-1][col]+1;
				node[ans].ope="DELETE";
				node[ans].index=row;
				node[ans].letter=s[row-1];
				irow=row-1;
				icol=col;
				updated=true;
			}
		}
		if (row>=0 && col-1>=0)
		{
			if (F[row][col-1]+1<min_v)
			{
				min_v=F[row][col-1]+1;
				node[ans].ope="INSERT";
				node[ans].index=col;
				node[ans].letter=t[col-1];
				irow=row;
				icol=col-1;
				updated=true;
			}
		}
		if (updated==true)
		{
			ans++;
		}
		row=irow;
		col=icol;

	}

	for (int i=ans-1; i>=0; i--)
	{
		cout<<node[i].ope<<" "<<node[i].index<<" "<<node[i].letter<<endl;
	}

	return 0;

}


#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <cstdio>
#include <cstring>
#include <utility>

using namespace std;

const int M=1000+5;

int F[M][M];

struct NODE{
	string ope;
	int index;
	char letter;
}node[M];

char a[M];
char b[M];

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	string s="";
	string t="";
	//cin>>s>>t;
	scanf("%s\n%s\n",a+1,b+1);
	int n=strlen(a+1);
	int m=strlen(b+1);

	cout<<n<<m<<endl;

	for (int i=0; i<n; i++)
	{
		s=s+a[i];
	}
	for (int i=0; i<m; i++)
	{
		t=t+b[i];
	}
	cout<<s<<endl;
	cout<<t<<endl;

	for (int col=1; col<=t.length(); col++)
	{
		F[0][col]=col;
	}
	for (int row=1; row<=s.length(); row++)
	{
		F[row][0]=row;
	}

	for (int row=1; row<=s.length(); row++)
	{
		for (int col=1; col<=t.length(); col++)
		{
			int tmp=F[row-1][col]+1;
			F[row][col]=tmp;
			if (F[row][col-1]+1<F[row][col])
			{
				F[row][col]=F[row][col-1]+1;
			}
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]<F[row][col])
				{
					F[row][col]=F[row-1][col-1];
				}
			}
			else
			{
				if (F[row-1][col-1]+1<F[row][col])
				{
					F[row][col]=F[row-1][col-1]+1;
				}
			}
		}
	}

	cout<<F[s.length()][t.length()]<<endl;

	int row=s.length();
	int col=t.length();
	int ans=0;
	while (row>=0 && col>=0)
	{
		int min_v=1E+9;
		int irow=-1;
		int icol=-1;
		bool updated=false;
		if (col-1>=0 && row-1>=0)
		{
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]<min_v)
				{
					min_v=F[row-1][col-1];
					irow=row-1;
					icol=col-1;
				}
			}
			else
			{
				if (F[row-1][col-1]+1<min_v)
				{
					min_v=F[row-1][col-1]+1;
					node[ans].ope="REPLACE";
					node[ans].index=col;
					node[ans].letter=t[col-1];
					irow=row-1;
					icol=col-1;
					updated=true;
				}
			}
		}
		if (row-1>=0 && col>=0)
		{
			if (F[row-1][col]+1<min_v)
			{
				min_v=F[row-1][col]+1;
				node[ans].ope="DELETE";
				node[ans].index=row;
				node[ans].letter=s[row-1];
				irow=row-1;
				icol=col;
				updated=true;
			}
		}
		if (row>=0 && col-1>=0)
		{
			if (F[row][col-1]+1<min_v)
			{
				min_v=F[row][col-1]+1;
				node[ans].ope="INSERT";
				node[ans].index=col;
				node[ans].letter=t[col-1];
				irow=row;
				icol=col-1;
				updated=true;
			}
		}
		if (updated==true)
		{
			ans++;
		}
		row=irow;
		col=icol;

	}

	for (int i=ans-1; i>=0; i--)
	{
		cout<<node[i].ope<<" "<<node[i].index<<" "<<node[i].letter<<endl;
	}

	return 0;

}


#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <utility>

using namespace std;

const int M=1000+5;

int F[M][M];

struct NODE{
	string ope;
	int index;
	char letter;
}node[M];

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	string s,t;
	cin>>s>>t;

	int ans=0;
	for (int col=1; col<=t.length(); col++)
	{
		F[0][col]=col;
	}
	for (int row=1; row<=s.length(); row++)
	{
		F[row][0]=row;
	}

	for (int row=1; row<=s.length(); row++)
	{
		for (int col=1; col<=t.length(); col++)
		{
			int tmp=F[row-1][col]+1;
			F[row][col]=tmp;
			if (F[row][col-1]+1<F[row][col])
			{
				F[row][col]=F[row][col-1]+1;
			}
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]<F[row][col])
				{
					F[row][col]=F[row-1][col-1];
				}
			}
			else
			{
				if (F[row-1][col-1]+1<F[row][col])
				{
					F[row][col]=F[row-1][col-1]+1;
				}
			}
		}
	}

	cout<<F[s.length()][t.length()]<<endl;

	int row=s.length();
	int col=t.length();

	while (row>=0 && col>=0)
	{
		int min_v=1E+9;
		int irow=-1;
		int icol=-1;
		bool updated=false;
		if (col-1>=0 && row-1>=0)
		{
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]<min_v)
				{
					min_v=F[row-1][col-1];
					irow=row-1;
					icol=col-1;
				}
			}
			else
			{
				if (F[row-1][col-1]+1<min_v)
				{
					min_v=F[row-1][col-1]+1;
					node[ans].ope="REPLACE";
					node[ans].index=col;
					node[ans].letter=t[col-1];
					irow=row-1;
					icol=col-1;
					updated=true;
				}
			}
		}
		if (row-1>=0 && col>=0)
		{
			if (F[row-1][col]+1<min_v)
			{
				min_v=F[row-1][col]+1;
				node[ans].ope="DELETE";
				node[ans].index=row;
				node[ans].letter=s[row-1];
				irow=row-1;
				icol=col;
				updated=true;
			}
		}
		if (row>=0 && col-1>=0)
		{
			if (F[row][col-1]+1<min_v)
			{
				min_v=F[row][col-1]+1;
				node[ans].ope="INSERT";
				node[ans].index=col;
				node[ans].letter=t[col-1];
				irow=row;
				icol=col-1;
				updated=true;
			}
		}
		if (updated==true)
		{
			ans++;
		}
		row=irow;
		col=icol;

	}

	for (int i=ans-1; i>=0; i--)
	{
		cout<<node[i].ope<<" "<<node[i].index<<" "<<node[i].letter<<endl;
	}

	return 0;

}


#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <utility>

using namespace std;

const int M=1000+5;

int F[M][M];

struct NODE{
	string ope;
	int index;
	char letter;
}node[M];

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	string s;
	string t;
	cin>>s>>t;
	int n=s.length();
	int m=t.length();

	for (int col=1; col<=m; col++)
	{
		F[0][col]=col;
	}
	for (int row=1; row<=n; row++)
	{
		F[row][0]=row;
	}

	for (int row=1; row<=n; row++)
	{
		for (int col=1; col<=m; col++)
		{
			int tmp=F[row-1][col]+1;
			F[row][col]=tmp;
			if (F[row][col-1]+1<F[row][col])
			{
				F[row][col]=F[row][col-1]+1;
			}
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]<F[row][col])
				{
					F[row][col]=F[row-1][col-1];
				}
			}
			else
			{
				if (F[row-1][col-1]+1<F[row][col])
				{
					F[row][col]=F[row-1][col-1]+1;
				}
			}
		}
	}

	cout<<F[n][m]<<endl;

	int row=n;
	int col=m;
	int ans=0;
	while (row>0 || col>0)
	{
		int min_v=1E+9;
		int irow=-1;
		int icol=-1;
		bool updated=false;
		if (col-1>=0 && row-1>=0)
		{
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]==F[row][col])
				{
					min_v=F[row-1][col-1];
					irow=row-1;
					icol=col-1;
				}
			}
			else
			{
				if (F[row-1][col-1]+1==F[row][col])
				{
					min_v=F[row-1][col-1]+1;
					node[ans].ope="REPLACE";
					node[ans].index=row;
					node[ans].letter=t[col-1];
					irow=row-1;
					icol=col-1;
					updated=true;
				}
			}
		}
		if (row-1>=0 && col>=0)
		{
			if (F[row-1][col]+1==F[row][col] && updated==false)
			{
				min_v=F[row-1][col]+1;
				node[ans].ope="DELETE";
				node[ans].index=row;
				node[ans].letter=s[row-1];
				irow=row-1;
				icol=col;
				updated=true;
			}
		}
		if (row>=0 && col-1>=0)
		{
			if (F[row][col-1]+1==F[row][col] && updated==false)
			{
				min_v=F[row][col-1]+1;
				node[ans].ope="INSERT";
				node[ans].index=row+1;
				node[ans].letter=t[col-1];
				irow=row;
				icol=col-1;
				updated=true;
			}
		}
		if (updated==true)
		{
			ans++;
		}
		row=irow;
		col=icol;

	}

	for (int i=0; i<ans; i++)
	{
		if (node[i].ope!="DELETE")
		{
			cout<<node[i].ope<<" "<<node[i].index<<" "<<node[i].letter<<endl;
		}
		else
		{
			cout<<node[i].ope<<" "<<node[i].index<<endl;
		}

	}

	return 0;

}


#include <stdlib.h>
#include <time.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <utility>

using namespace std;

const int M=1000+5;

int F[M][M];

struct NODE{
	string ope;
	int index;
	char letter;
}node[M];

char a[M];
char b[M];

int main()
{

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	string s;
	string t;
	//cin>>s>>t;
	getline(cin,s);
	getline(cin,t);

	for (int col=1; col<=t.length(); col++)
	{
		F[0][col]=col;
	}
	for (int row=1; row<=s.length(); row++)
	{
		F[row][0]=row;
	}

	for (int row=1; row<=s.length(); row++)
	{
		for (int col=1; col<=t.length(); col++)
		{
			int tmp=F[row-1][col]+1;
			F[row][col]=tmp;
			if (F[row][col-1]+1<F[row][col])
			{
				F[row][col]=F[row][col-1]+1;
			}
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]<F[row][col])
				{
					F[row][col]=F[row-1][col-1];
				}
			}
			else
			{
				if (F[row-1][col-1]+1<F[row][col])
				{
					F[row][col]=F[row-1][col-1]+1;
				}
			}
		}
	}

	cout<<F[s.length()][t.length()]<<endl;

	int row=s.length();
	int col=t.length();
	int ans=0;
	while (row>=0 && col>=0)
	{
		int min_v=1E+9;
		int irow=-1;
		int icol=-1;
		bool updated=false;
		if (col-1>=0 && row-1>=0)
		{
			if (s[row-1]==t[col-1])
			{
				if (F[row-1][col-1]<min_v)
				{
					min_v=F[row-1][col-1];
					irow=row-1;
					icol=col-1;
				}
			}
			else
			{
				if (F[row-1][col-1]+1<min_v)
				{
					min_v=F[row-1][col-1]+1;
					node[ans].ope="REPLACE";
					node[ans].index=col;
					node[ans].letter=t[col-1];
					irow=row-1;
					icol=col-1;
					updated=true;
				}
			}
		}
		if (row-1>=0 && col>=0)
		{
			if (F[row-1][col]+1<min_v)
			{
				min_v=F[row-1][col]+1;
				node[ans].ope="DELETE";
				node[ans].index=row;
				node[ans].letter=s[row-1];
				irow=row-1;
				icol=col;
				updated=true;
			}
		}
		if (row>=0 && col-1>=0)
		{
			if (F[row][col-1]+1<min_v)
			{
				min_v=F[row][col-1]+1;
				node[ans].ope="INSERT";
				node[ans].index=col;
				node[ans].letter=t[col-1];
				irow=row;
				icol=col-1;
				updated=true;
			}
		}
		if (updated==true)
		{
			ans++;
		}
		row=irow;
		col=icol;

	}

	for (int i=ans-1; i>=0; i--)
	{
		cout<<node[i].ope<<" "<<node[i].index<<" "<<node[i].letter<<endl;
	}

	return 0;

}


#include <stdio.h>
#include <string.h>
#include <iostream>
#define INSERT 2
#define REMOVE 3
#define REPLACE 5
#define BLANK 6
using namespace std;
int process[1001][1001];
int steps[1001][1001];
char s[1001],t[1001];
int currspot=1;
void printSteps(int i,int j) {
	if (process[i][j]==REPLACE) {
		printSteps(i-1,j-1);
		cout<<"REPLACE "<<currspot<<" "<<t[j-1]<<"\n";
		currspot++;
	} else if (process[i][j]==INSERT) {
		printSteps(i,j-1);
		cout<<"INSERT "<<currspot<<" "<<t[j-1]<<"\n";
		currspot++;
	} else if (process[i][j]==REMOVE) {
		printSteps(i-1,j);
		cout<<"DELETE "<<currspot<<"\n";
		//currspot--;
	} else if (process[i][j]==BLANK) {
		printSteps(i-1,j-1);
		currspot++;
	}
}
int main() {
	//freopen("56D.inp","r",stdin);
	//freopen(".out","w",stdout);
	cin>>s>>t;
	//memset(steps,0,sizeof(steps));
	for (int i=1;i<=strlen(t);i++) {
		steps[0][i]=i;
		process[0][i]=INSERT;
	}
	for (int i=1;i<=strlen(s);i++) {
		steps[i][0]=i;
		process[i][0]=REMOVE;
	}
	for (int i=1;i<=strlen(s);i++) {
		for (int j=1;j<=strlen(t);j++) {
			//cout<<"s["<<i<<"-1]="<<s[i-1]<<" t["<<j<<"-1]="<<t[j-1]<<"\n";
			if (s[i-1]==t[j-1]) {
				steps[i][j]=steps[i-1][j-1];
				process[i][j]=BLANK;
			}
			else {
				int remove=steps[i-1][j];
				int insert=steps[i][j-1];
				int replace=steps[i-1][j-1];
				steps[i][j]=min(remove,min(insert,replace))+1;
				if (steps[i][j]==insert+1) {
					process[i][j]=INSERT;
				}
				else if (steps[i][j]==remove+1) {
					process[i][j]=REMOVE;
				}
				else if (steps[i][j]==replace+1) process[i][j]=REPLACE;
				//cout<<"process["<<i<<"]["<<j<<"]="<<process[i][j]<<"\n";
			}
		}
	}
	cout<<steps[strlen(s)][strlen(t)]<<"\n";
	//cout<<"PRINT STEPS:\n";
	printSteps(strlen(s),strlen(t));
}


#include <stdio.h>
#include <string.h>
#include <iostream>
#define INSERT 2
#define REMOVE 3
#define REPLACE 5
#define BLANK 6
using namespace std;
int process[1001][1001];
int steps[1001][1001];
char s[1001],t[1001];
int currspot=1;
void printSteps(int i,int j) {
	if (process[i][j]==REPLACE) {
		printSteps(i-1,j-1);
		cout<<"REPLACE "<<currspot<<" "<<t[j-1]<<"\n";
		currspot++;
	} else if (process[i][j]==INSERT) {
		printSteps(i,j-1);
		cout<<"INSERT "<<currspot<<" "<<t[j-1]<<"\n";
		currspot++;
	} else if (process[i][j]==REMOVE) {
		printSteps(i-1,j);
		cout<<"DELETE "<<currspot<<"\n";
		//currspot--;
	} else if (process[i][j]==BLANK) {
		printSteps(i-1,j-1);
		currspot++;
	}
}
int main() {
	//freopen("56D.inp","r",stdin);
	//freopen(".out","w",stdout);
	cin>>s>>t;
	memset(steps,0,sizeof(steps));
	for (int i=1;i<=strlen(t);i++) steps[0][i]=i;
	for (int i=1;i<=strlen(s);i++) steps[i][0]=i;
	for (int i=1;i<=strlen(s);i++) {
		for (int j=1;j<=strlen(t);j++) {
			//cout<<"s["<<i<<"-1]="<<s[i-1]<<" t["<<j<<"-1]="<<t[j-1]<<"\n";
			if (s[i-1]==t[j-1]) {
				steps[i][j]=steps[i-1][j-1];
				process[i][j]=BLANK;
			}
			else {
				int remove=steps[i-1][j];
				int insert=steps[i][j-1];
				int replace=steps[i-1][j-1];
				steps[i][j]=min(remove,min(insert,replace))+1;
				if (steps[i][j]==insert+1) {
					process[i][j]=INSERT;
				}
				else if (steps[i][j]==remove+1) {
					process[i][j]=REMOVE;
				}
				else if (steps[i][j]==replace+1) process[i][j]=REPLACE;
				//cout<<"process["<<i<<"]["<<j<<"]="<<process[i][j]<<"\n";
			}
		}
	}
	cout<<steps[strlen(s)][strlen(t)]<<"\n";
	//cout<<"PRINT STEPS:\n";
	printSteps(strlen(s),strlen(t));
}


#include <stdio.h>
#include <string.h>
#include <iostream>
#define INSERT 2
#define REMOVE 3
#define REPLACE 5
#define BLANK 6
using namespace std;
int process[1001][1001];
int steps[1001][1001];
char s[1001],t[1001];
int currspot=1;
void printSteps(int i,int j) {
	if (process[i][j]==REPLACE) {
		printSteps(i-1,j-1);
		cout<<"REPLACE "<<currspot<<" "<<t[j-1]<<"\n";
		currspot++;
	} else if (process[i][j]==INSERT) {
		printSteps(i,j-1);
		cout<<"INSERT "<<currspot<<" "<<t[j-1]<<"\n";
		currspot++;
	} else if (process[i][j]==REMOVE) {
		printSteps(i-1,j);
		cout<<"DELETE "<<currspot<<"\n";
		//currspot--;
	} else if (process[i][j]==BLANK) {
		printSteps(i-1,j-1);
		currspot++;
	}
}
int main() {
	//freopen("56D.inp","r",stdin);
	//freopen(".out","w",stdout);
	cin>>s>>t;
	//memset(steps,0,sizeof(steps));
	for (int i=1;i<=strlen(t);i++) {
		steps[0][i]=i;
		process[i][0]=INSERT;
	}
	for (int i=1;i<=strlen(s);i++) {
		steps[i][0]=i;
		process[i][0]=REMOVE;
	}
	for (int i=1;i<=strlen(s);i++) {
		for (int j=1;j<=strlen(t);j++) {
			//cout<<"s["<<i<<"-1]="<<s[i-1]<<" t["<<j<<"-1]="<<t[j-1]<<"\n";
			if (s[i-1]==t[j-1]) {
				steps[i][j]=steps[i-1][j-1];
				process[i][j]=BLANK;
			}
			else {
				int remove=steps[i-1][j];
				int insert=steps[i][j-1];
				int replace=steps[i-1][j-1];
				steps[i][j]=min(remove,min(insert,replace))+1;
				if (steps[i][j]==insert+1) {
					process[i][j]=INSERT;
				}
				else if (steps[i][j]==remove+1) {
					process[i][j]=REMOVE;
				}
				else if (steps[i][j]==replace+1) process[i][j]=REPLACE;
				//cout<<"process["<<i<<"]["<<j<<"]="<<process[i][j]<<"\n";
			}
		}
	}
	cout<<steps[strlen(s)][strlen(t)]<<"\n";
	//cout<<"PRINT STEPS:\n";
	printSteps(strlen(s),strlen(t));
}


#include <stdio.h>
#include <string.h>
#include <iostream>
#define INSERT 2
#define REMOVE 3
#define REPLACE 5
#define BLANK 6
using namespace std;
int process[1001][1001];
int steps[1001][1001];
char s[1001],t[1001];
int currspot=1;
void printSteps(int i,int j) {
	if (process[i][j]==REPLACE) {
		printSteps(i-1,j-1);
		cout<<"REPLACE "<<currspot<<" "<<t[j-1]<<"\n";
		currspot++;
	} else if (process[i][j]==INSERT) {
		printSteps(i,j-1);
		cout<<"INSERT "<<currspot<<" "<<t[j-1]<<"\n";
		currspot++;
	} else if (process[i][j]==REMOVE) {
		printSteps(i-1,j);
		cout<<"DELETE "<<currspot<<"\n";
		currspot--;
	} else if (process[i][j]==BLANK) {
		printSteps(i-1,j-1);
		currspot++;
	}
}
int main() {
	//freopen("56D.inp","r",stdin);
	//freopen(".out","w",stdout);
	cin>>s>>t;
	memset(steps,0,sizeof(steps));
	for (int i=1;i<=strlen(t);i++) steps[0][i]=i;
	for (int i=1;i<=strlen(s);i++) steps[i][0]=i;
	for (int i=1;i<=strlen(s);i++) {
		for (int j=1;j<=strlen(t);j++) {
			//cout<<"s["<<i<<"-1]="<<s[i-1]<<" t["<<j<<"-1]="<<t[j-1]<<"\n";
			if (s[i-1]==t[j-1]) {
				steps[i][j]=steps[i-1][j-1];
				process[i][j]=BLANK;
			}
			else {
				int remove=steps[i-1][j];
				int insert=steps[i][j-1];
				int replace=steps[i-1][j-1];
				steps[i][j]=min(remove,min(insert,replace))+1;
				if (steps[i][j]==insert+1) {
					process[i][j]=INSERT;
				}
				else if (steps[i][j]==remove+1) {
					process[i][j]=REMOVE;
				}
				else if (steps[i][j]==replace+1) process[i][j]=REPLACE;
				//cout<<"process["<<i<<"]["<<j<<"]="<<process[i][j]<<"\n";
			}
		}
	}
	cout<<steps[strlen(s)][strlen(t)]<<"\n";
	//cout<<"PRINT STEPS:\n";
	printSteps(strlen(s),strlen(t));
}


#include <bits/stdc++.h>
#define INSERT 2
#define REMOVE 3
#define REPLACE 5
#define BLANK 6
using namespace std;
int process[1001][1001];
int steps[1001][1001];
char s[1001],t[1001];
int currspot=1;
void printSteps(int i,int j) {
	if (process[i][j]==REPLACE) {
		printSteps(i-1,j-1);
		cout<<"REPLACE "<<currspot<<" "<<t[j-1]<<"\n";
		currspot++;
	} else if (process[i][j]==INSERT) {
		printSteps(i,j-1);
		cout<<"INSERT "<<currspot<<" "<<t[j-1]<<"\n";
		currspot++;
	} else if (process[i][j]==REMOVE) {
		printSteps(i-1,j);
		cout<<"REMOVE "<<currspot<<" "<<t[j-1]<<"\n";
		currspot--;
	} else if (process[i][j]==BLANK) {
		printSteps(i-1,j-1);
		currspot++;
	}
}
int main() {
	//freopen("56D.inp","r",stdin);
	//freopen(".out","w",stdout);
	cin>>s>>t;
	memset(steps,0,sizeof(steps));
	for (int i=1;i<=strlen(t);i++) steps[0][i]=i;
	for (int i=1;i<=strlen(s);i++) steps[i][0]=i;
	for (int i=1;i<=strlen(s);i++) {
		for (int j=1;j<=strlen(t);j++) {
			//cout<<"s["<<i<<"-1]="<<s[i-1]<<" t["<<j<<"-1]="<<t[j-1]<<"\n";
			if (s[i-1]==t[j-1]) {
				steps[i][j]=steps[i-1][j-1];
				process[i][j]=BLANK;
			}
			else {
				int remove=steps[i-1][j];
				int insert=steps[i][j-1];
				int replace=steps[i-1][j-1];
				steps[i][j]=min(remove,min(insert,replace))+1;
				if (steps[i][j]==insert+1) {
					process[i][j]=INSERT;
				}
				else if (steps[i][j]==remove+1) {
					process[i][j]=REMOVE;
				}
				else if (steps[i][j]==replace+1) process[i][j]=REPLACE;
				//cout<<"process["<<i<<"]["<<j<<"]="<<process[i][j]<<"\n";
			}
		}
	}
	cout<<steps[strlen(s)][strlen(t)]<<"\n";
	//cout<<"PRINT STEPS:\n";
	printSteps(strlen(s),strlen(t));
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<vector>
using namespace std;

char s[2005],t[2005];
int dp[2005][2005];
int main()
{
    while (scanf("%s%s",s+1,t+1)>0)
    {
        int len1=strlen(s+1),len2=strlen(t+1);
        memset(dp,127,sizeof(dp));
        dp[0][0]=0;
        for (int i=1;i<=len1;i++) dp[i][0]=i;
        for (int i=1;i<=len2;i++) dp[0][i]=i;
        for (int i=1;i<=len1;i++)
            for (int j=1;j<=len2;j++)
            {
                if (s[i]==t[j]) dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
                else dp[i][j]=min(dp[i][j],dp[i-1][j-1]+1);
                dp[i][j]=min(dp[i][j],min(dp[i-1][j]+1,dp[i][j-1]+1));
            }
        printf("%d\n",dp[len1][len2]);
        int i=len1,j=len2;
        while (true)
        {
            if (dp[i][j]==dp[i-1][j]+1 && i>=1)
            {
                printf("DELETE %d\n",i);
                i--;
            }
            else if (dp[i][j]==dp[i][j-1]+1 && j>=1)
            {
                printf("INSERT %d %c\n",i+1,t[j]);
                j--;
            }
            else if (dp[i-1][j-1]+1==dp[i][j])
            {
                printf("REPLACE %d %c\n",i,t[j]);
                i--;j--;
            }
            else
            {
                i--;j--;
            }
            //printf("%d %d\n",i,j);
            if (i==0 && j==0) break;
        }
    }
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<vector>
using namespace std;

char s[1005],t[1005];
int dp[1005][1005];
int main()
{
	while (scanf("%s%s",s+1,t+1)>0)
	{
		int len1=strlen(s+1),len2=strlen(t+1);
		memset(dp,127,sizeof(dp));
		dp[0][0]=0;
		for (int i=1;i<=len1;i++) dp[i][0]=i;
		for (int i=1;i<=len2;i++) dp[0][i]=i;
		for (int i=1;i<=len1;i++)
			for (int j=1;j<=len2;j++)
			{
				if (s[i]==t[j]) dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
				else dp[i][j]=min(dp[i][j],dp[i-1][j-1]+1);
				dp[i][j]=min(dp[i][j],min(dp[i-1][j]+1,dp[i][j-1]+1));
			}
		printf("%d\n",dp[len1][len2]);
		int i=len1,j=len2;
		while (true)
		{
			if (dp[i][j]==dp[i-1][j]+1)
			{
				printf("DELETE %d\n",i);
				i--;
			}
			else if (dp[i][j]==dp[i][j-1]+1)
			{
				printf("INSERT %d %c\n",i+1,t[j]);
				j--;
			}
			else if (dp[i-1][j-1]+1==dp[i][j])
			{
				printf("REPLACE %d %c\n",i,t[j]);
				i--;j--;
			}
			else
			{
				i--;j--;
			}
			if (i==0 && j==0) break;
		}
	}
}


#include <iostream>
#include <string>

using namespace std;

const int MN = 1000 + 10;
const int inf = 2000 * 1000 * 1000;

string s1, s2;
int dp[MN][MN];

int solve(int i, int j) {
	if (i == s1.size() && j == s2.size())
		return 0;
	if (i > s1.size() || j > s2.size())
		return inf;
	if (dp[i][j] != inf)
		return dp[i][j];
	int a[4];
	a[0] = solve(i + 1, j) + 1;
	a[1] = solve(i, j + 1) + 1;
	a[2] = solve(i + 1, j + 1) + 1;
	a[3] = inf;
	if (i < s1.size() && j < s2.size() && s1[i] == s2[j])
		a[3] = solve(i + 1, j + 1);
	int tmp = 3;
	for(int k = 0; k < 4; k ++)
		if (a[k] < dp[i][j])
			dp[i][j] = a[k];
	return dp[i][j];
}

int main() {
	cin >> s1 >> s2;
	fill(&dp[0][0], &dp[0][0] + MN * MN, inf);
	dp[s1.size()][s2.size()] = 0;
	cout << solve(0, 0);
	cout << endl;
	int x = 0;
	int y = 0;
	while (x <= s1.size() || y <= s2.size()) {
		if (dp[x][y] == dp[x + 1][y] + 1)
			cout << "DELETE " << ++ x << " " << endl;
		else if (dp[x][y] == dp[x][y + 1] + 1)
			cout << "INSERT " << y + 1 << " " << s2[y ++] << endl;
		else if (dp[x][y] == dp[x + 1][y + 1] + 1)
			cout << "REPLACE " << ++ x << " " << s2[y ++] << endl;
		else {
			x ++;
			y ++;
		}
	}
	return 0;
}


#include <iostream>
#include <string>

using namespace std;

const int MN = 1000 + 10;
const int inf = 2000 * 1000 * 1000;

string s1, s2;
int dp[MN][MN];

int solve(int i, int j) {
	if (i == s1.size() && j == s2.size())
		return 0;
	if (i > s1.size() || j > s2.size())
		return inf;
	if (dp[i][j] != inf)
		return dp[i][j];
	int a[4];
	a[0] = solve(i + 1, j) + 1;
	a[1] = solve(i, j + 1) + 1;
	a[2] = solve(i + 1, j + 1) + 1;
	a[3] = inf;
	if (i < s1.size() && j < s2.size() && s1[i] == s2[j])
		a[3] = solve(i + 1, j + 1);
	int tmp = 3;
	for(int k = 0; k < 4; k ++)
		if (a[k] < dp[i][j])
			dp[i][j] = a[k];
	return dp[i][j];
}

int main() {
	cin >> s1 >> s2;
	fill(&dp[0][0], &dp[0][0] + MN * MN, inf);
	dp[s1.size()][s2.size()] = 0;
	cout << solve(0, 0);
	cout << endl;
	int x = 0;
	int y = 0;
	int pos = 1;
	while (x <= s1.size() || y <= s2.size()) {
		if (dp[x][y] == dp[x + 1][y] + 1) {
			cout << "DELETE " << pos << " " << endl;
			x ++;
		}
		else if (dp[x][y] == dp[x][y + 1] + 1) {
			cout << "INSERT " << pos << " " << s2[y] << endl;
			y ++;
			pos ++;
		}
		else if (dp[x][y] == dp[x + 1][y + 1] + 1) {
			cout << "REPLACE " << pos << " " << s2[y] << endl;
			x ++;
			y ++;
			pos ++;
		}
		else {
			x ++;
			y ++;
			pos ++;
		}
	}
	return 0;
}


#include <iostream>
#include <string>

using namespace std;

const int MN = 1000 + 10;
const int inf = 2000 * 1000 * 1000;

string s1, s2;
int dp[MN][MN];

int solve(int i, int j) {
	if (i == s1.size() && j == s2.size())
		return 0;
	if (i > s1.size() || j > s2.size())
		return inf;
	if (dp[i][j] != inf)
		return dp[i][j];
	int a[4];
	a[0] = solve(i + 1, j) + 1;
	a[1] = solve(i, j + 1) + 1;
	a[2] = solve(i + 1, j + 1) + 1;
	a[3] = inf;
	if (i < s1.size() && j < s2.size() && s1[i] == s2[j])
		a[3] = solve(i + 1, j + 1);
	int tmp = 3;
	for(int k = 0; k < 4; k ++)
		if (a[k] < dp[i][j])
			dp[i][j] = a[k];
	return dp[i][j];
}

int main() {
	cin >> s1 >> s2;
	fill(&dp[0][0], &dp[0][0] + MN * MN, inf);
	dp[s1.size()][s2.size()] = 0;
	cout << solve(0, 0);
	cout << endl;
	int x = 0;
	int y = 0;
	while (x <= s1.size() || y <= s2.size()) {
		if (dp[x][y] == dp[x + 1][y] + 1)
			cout << "DELETE " << ++ x << " " << endl;
		else if (dp[x][y] == dp[x][y + 1] + 1) {
			cout << "INSERT " << y + 1 << " " << s2[y] << endl;
			y ++;
		}
		else if (dp[x][y] == dp[x + 1][y + 1] + 1) {
			cout << "REPLACE " << y + 1 << " " << s2[y] << endl;
			x ++;
			y ++;
		}
		else {
			x ++;
			y ++;
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <iostream>
#include <memory.h>
#include <assert.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <math.h>

#define fo(a,b,c) for( a = ( b ); a < ( c ); ++ a )
#define fr(a,b) fo( a, 0, ( b ) )
#define fi(a) fr( i, ( a ) )
#define fj(a) fr( j, ( a ) )
#define fk(a) fr( k, ( a ) )
#define mp make_pair
#define pb push_back
#define all(v) (v).begin( ), (v).end( )
#define _(a,b) memset( a, b, sizeof( a ) )
using namespace std;
int ni() { int a; scanf( "%d", &a ); return a; }
double nf() { double a; scanf( "%lf", &a ); return a; }
char sbuf[100005]; string ns() { scanf( "%s", sbuf ); return sbuf; }
long long nll() { long long a; scanf( "%lld", &a ); return a; }

template <class T> void out( T a, T b ) { bool first = true; for( T i = a; i != b; ++ i ) { if( !first ) printf( " " ); first = false; cout << * i; } printf( "\n" ); }
template <class T> void outl( T a, T b ) { for( T i = a; i != b; ++ i ) { cout << * i << "\n"; } }
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef map<string,int> msi;

int n, m;
int d[1005][1005];
int is[1005][1005];

int main( )
{
    int i, j, k;

//  freopen( "input.txt", "r", stdin );
//  freopen( "output.txt", "w", stdout );

    string s = ns( );
    string r = ns( );
    fi( s.size( ) + 1 ) d[i][0] = i;
    fi( r.size( ) + 1 ) d[0][i] = i;
    fi( s.size( ) + 1 ) if( i ) fj( r.size( ) + 1 ) if( j ) {
        d[i][j] = min( d[i - 1][j] + 1, d[i][j - 1] + 1 );
        if( s[i - 1] == r[j - 1] ) d[i][j] = min( d[i][j], d[i - 1][j - 1] );
        else d[i][j] = min( d[i][j], d[i - 1][j - 1] + 1 );
        if( d[i][j] == d[i][j - 1] + 1 ) {
            is[i][j] = is[i][j - 1] + 1;
        }
        else if( d[i][j] == d[i - 1][j] + 1 ) is[i][j] = is[i - 1][j];
        else is[i][j] = is[i - 1][j - 1] + 1;
    }
    printf( "%d\n", d[s.size( )][r.size( )] );
    vs ans;
    int n = s.size( );
    int m = r.size( );
    while( n || m ) {
        if( m && d[n][m - 1] + 1 == d[n][m] ) {
            sprintf( sbuf, "INSERT %d %c", is[n][m], r[m - 1] );
            ans.pb( sbuf );
            -- m;
        }
        else if( n && d[n - 1][m] + 1 == d[n][m] ) {
            sprintf( sbuf, "DELETE %d", is[n][m] + 1 );
            ans.pb( sbuf );
            -- n;
        }
        else if( n && m && d[n - 1][m - 1] + 1 == d[n][m] ) {
            sprintf( sbuf, "REPLACE %d %c", is[n][m], r[m - 1] );
            ans.pb( sbuf );
            -- n; -- m;
        } else { -- n; -- m; }
    }
    reverse( all( ans ) );
    outl( all( ans ) );

    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <iostream>
#include <memory.h>
#include <assert.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <math.h>

#define fo(a,b,c) for( a = ( b ); a < ( c ); ++ a )
#define fr(a,b) fo( a, 0, ( b ) )
#define fi(a) fr( i, ( a ) )
#define fj(a) fr( j, ( a ) )
#define fk(a) fr( k, ( a ) )
#define mp make_pair
#define pb push_back
#define all(v) (v).begin( ), (v).end( )
#define _(a,b) memset( a, b, sizeof( a ) )
using namespace std;
int ni() { int a; scanf( "%d", &a ); return a; }
double nf() { double a; scanf( "%lf", &a ); return a; }
char sbuf[100005]; string ns() { scanf( "%s", sbuf ); return sbuf; }
long long nll() { long long a; scanf( "%lld", &a ); return a; }

template <class T> void out( T a, T b ) { bool first = true; for( T i = a; i != b; ++ i ) { if( !first ) printf( " " ); first = false; cout << * i; } printf( "\n" ); }
template <class T> void outl( T a, T b ) { for( T i = a; i != b; ++ i ) { cout << * i << "\n"; } }
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef map<string,int> msi;

int n, m;
int d[1005][1005];
int is[1005][1005];

int main( )
{
    int i, j, k;

//  freopen( "input.txt", "r", stdin );
//  freopen( "output.txt", "w", stdout );

    string s = ns( );
    string r = ns( );
    fi( s.size( ) + 1 ) d[i][0] = i;
    fi( r.size( ) + 1 ) { d[0][i] = i; is[0][i] = i; }
    fi( s.size( ) + 1 ) if( i ) fj( r.size( ) + 1 ) if( j ) {
        d[i][j] = min( d[i - 1][j] + 1, d[i][j - 1] + 1 );
        if( s[i - 1] == r[j - 1] ) d[i][j] = min( d[i][j], d[i - 1][j - 1] );
        else d[i][j] = min( d[i][j], d[i - 1][j - 1] + 1 );
        if( d[i][j] == d[i][j - 1] + 1 ) {
            is[i][j] = is[i][j - 1] + 1;
        }
        else if( d[i][j] == d[i - 1][j] + 1 ) is[i][j] = is[i - 1][j];
        else is[i][j] = is[i - 1][j - 1] + 1;
    }
    printf( "%d\n", d[s.size( )][r.size( )] );
    vs ans;
    int n = s.size( );
    int m = r.size( );
    while( n || m ) {
        if( m && d[n][m - 1] + 1 == d[n][m] ) {
            sprintf( sbuf, "INSERT %d %c", is[n][m], r[m - 1] );
            ans.pb( sbuf );
            -- m;
        }
        else if( n && d[n - 1][m] + 1 == d[n][m] ) {
            sprintf( sbuf, "DELETE %d", is[n][m] + 1 );
            ans.pb( sbuf );
            -- n;
        }
        else if( n && m && d[n - 1][m - 1] + 1 == d[n][m] ) {
            sprintf( sbuf, "REPLACE %d %c", is[n][m], r[m - 1] );
            ans.pb( sbuf );
            -- n; -- m;
        } else { -- n; -- m; }
    }
    reverse( all( ans ) );
    outl( all( ans ) );

    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <iostream>
#include <memory.h>
#include <assert.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <math.h>

#define fo(a,b,c) for( a = ( b ); a < ( c ); ++ a )
#define fr(a,b) fo( a, 0, ( b ) )
#define fi(a) fr( i, ( a ) )
#define fj(a) fr( j, ( a ) )
#define fk(a) fr( k, ( a ) )
#define mp make_pair
#define pb push_back
#define all(v) (v).begin( ), (v).end( )
#define _(a,b) memset( a, b, sizeof( a ) )
using namespace std;
int ni() { int a; scanf( "%d", &a ); return a; }
double nf() { double a; scanf( "%lf", &a ); return a; }
char sbuf[100005]; string ns() { scanf( "%s", sbuf ); return sbuf; }
long long nll() { long long a; scanf( "%lld", &a ); return a; }

template <class T> void out( T a, T b ) { bool first = true; for( T i = a; i != b; ++ i ) { if( !first ) printf( " " ); first = false; cout << * i; } printf( "\n" ); }
template <class T> void outl( T a, T b ) { for( T i = a; i != b; ++ i ) { cout << * i << "\n"; } }
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef map<string,int> msi;

int n, m;
int d[1005][1005];
int is[1005][1005];

int main( )
{
    int i, j, k;

//  freopen( "input.txt", "r", stdin );
//  freopen( "output.txt", "w", stdout );

    string s = ns( );
    string r = ns( );
    fi( s.size( ) + 1 ) d[i][0] = i;
    fi( r.size( ) + 1 ) d[0][i] = i;
    fi( s.size( ) + 1 ) if( i ) fj( r.size( ) + 1 ) if( j ) {
        d[i][j] = min( d[i - 1][j] + 1, d[i][j - 1] + 1 );
        if( s[i - 1] == r[j - 1] ) d[i][j] = min( d[i][j], d[i - 1][j - 1] );
        else d[i][j] = min( d[i][j], d[i - 1][j - 1] + 1 );
        if( d[i][j] == d[i][j - 1] + 1 ) {
            is[i][j] = is[i][j - 1] + 1;
        }
        else if( d[i][j] == d[i - 1][j] + 1 ) is[i][j] = is[i - 1][j];
        else is[i][j] = is[i - 1][j - 1];
    }
    printf( "%d\n", d[s.size( )][r.size( )] );
    vs ans;
    int n = s.size( );
    int m = r.size( );
    while( n || m ) {
        if( m && d[n][m - 1] + 1 == d[n][m] ) {
            sprintf( sbuf, "INSERT %d %c", n + is[n][m], r[m - 1] );
            ans.pb( sbuf );
            -- m;
        }
        else if( n && d[n - 1][m] + 1 == d[n][m] ) {
            sprintf( sbuf, "DELETE %d", n + is[n][m] );
            ans.pb( sbuf );
            -- n;
        }
        else if( n && m && d[n - 1][m - 1] + 1 == d[n][m] ) {
            sprintf( sbuf, "REPLACE %d %c", n + is[n][m], r[m - 1] );
            ans.pb( sbuf );
            -- n; -- m;
        } else { -- n; -- m; }
    }
    reverse( all( ans ) );
    outl( all( ans ) );

    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <iostream>
#include <memory.h>
#include <assert.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <math.h>

#define fo(a,b,c) for( a = ( b ); a < ( c ); ++ a )
#define fr(a,b) fo( a, 0, ( b ) )
#define fi(a) fr( i, ( a ) )
#define fj(a) fr( j, ( a ) )
#define fk(a) fr( k, ( a ) )
#define mp make_pair
#define pb push_back
#define all(v) (v).begin( ), (v).end( )
#define _(a,b) memset( a, b, sizeof( a ) )
using namespace std;
int ni() { int a; scanf( "%d", &a ); return a; }
double nf() { double a; scanf( "%lf", &a ); return a; }
char sbuf[100005]; string ns() { scanf( "%s", sbuf ); return sbuf; }
long long nll() { long long a; scanf( "%lld", &a ); return a; }

template <class T> void out( T a, T b ) { bool first = true; for( T i = a; i != b; ++ i ) { if( !first ) printf( " " ); first = false; cout << * i; } printf( "\n" ); }
template <class T> void outl( T a, T b ) { for( T i = a; i != b; ++ i ) { cout << * i << "\n"; } }
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef map<string,int> msi;

int n, m;
int d[1005][1005];
int is[1005][1005];

int main( )
{
    int i, j, k;

//  freopen( "input.txt", "r", stdin );
//  freopen( "output.txt", "w", stdout );

    string s = ns( );
    string r = ns( );
    fi( s.size( ) + 1 ) d[i][0] = i;
    fi( r.size( ) + 1 ) d[0][i] = i;
    fi( s.size( ) + 1 ) if( i ) fj( r.size( ) + 1 ) if( j ) {
        d[i][j] = min( d[i - 1][j] + 1, d[i][j - 1] + 1 );
        if( s[i - 1] == r[j - 1] ) d[i][j] = min( d[i][j], d[i - 1][j - 1] );
        else d[i][j] = min( d[i][j], d[i - 1][j - 1] + 1 );
        if( d[i][j] == d[i][j - 1] + 1 ) {
            is[i][j] = is[i][j - 1] + 1;
        }
        else if( d[i][j] == d[i - 1][j] + 1 ) is[i][j] = is[i - 1][j] - 1;
        else is[i][j] = is[i - 1][j - 1];
    }
    printf( "%d\n", d[s.size( )][r.size( )] );
    vs ans;
    int n = s.size( );
    int m = r.size( );
    while( n || m ) {
        if( m && d[n][m - 1] + 1 == d[n][m] ) {
            sprintf( sbuf, "INSERT %d %c", n + is[n][m], r[m - 1] );
            ans.pb( sbuf );
            -- m;
        }
        else if( n && d[n - 1][m] + 1 == d[n][m] ) {
            sprintf( sbuf, "DELETE %d", n + is[n][m] + 1 );
            ans.pb( sbuf );
            -- n;
        }
        else if( n && m && d[n - 1][m - 1] + 1 == d[n][m] ) {
            sprintf( sbuf, "REPLACE %d %c", n + is[n][m], r[m - 1] );
            ans.pb( sbuf );
            -- n; -- m;
        } else { -- n; -- m; }
    }
    reverse( all( ans ) );
    outl( all( ans ) );

    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <iostream>
#include <memory.h>
#include <assert.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <math.h>

#define fo(a,b,c) for( a = ( b ); a < ( c ); ++ a )
#define fr(a,b) fo( a, 0, ( b ) )
#define fi(a) fr( i, ( a ) )
#define fj(a) fr( j, ( a ) )
#define fk(a) fr( k, ( a ) )
#define mp make_pair
#define pb push_back
#define all(v) (v).begin( ), (v).end( )
#define _(a,b) memset( a, b, sizeof( a ) )
using namespace std;
int ni() { int a; scanf( "%d", &a ); return a; }
double nf() { double a; scanf( "%lf", &a ); return a; }
char sbuf[100005]; string ns() { scanf( "%s", sbuf ); return sbuf; }
long long nll() { long long a; scanf( "%lld", &a ); return a; }

template <class T> void out( T a, T b ) { bool first = true; for( T i = a; i != b; ++ i ) { if( !first ) printf( " " ); first = false; cout << * i; } printf( "\n" ); }
template <class T> void outl( T a, T b ) { for( T i = a; i != b; ++ i ) { cout << * i << "\n"; } }
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef map<string,int> msi;

int n, m;
int d[1005][1005];
int is[1005][1005];

int main( )
{
    int i, j, k;

//  freopen( "input.txt", "r", stdin );
//  freopen( "output.txt", "w", stdout );

    string s = ns( );
    string r = ns( );
    fi( s.size( ) + 1 ) d[i][0] = i;
    fi( r.size( ) + 1 ) d[0][i] = i;
    fi( s.size( ) + 1 ) if( i ) fj( r.size( ) + 1 ) if( j ) {
        d[i][j] = min( d[i - 1][j] + 1, d[i][j - 1] + 1 );
        if( s[i - 1] == r[j - 1] ) d[i][j] = min( d[i][j], d[i - 1][j - 1] );
        else d[i][j] = min( d[i][j], d[i - 1][j - 1] + 1 );
        if( d[i][j] == d[i][j - 1] + 1 ) {
            is[i][j] = is[i][j - 1] + 1;
        }
        else if( d[i][j] == d[i - 1][j] + 1 ) is[i][j] = is[i - 1][j];
        else is[i][j] = is[i - 1][j - 1];
    }
    printf( "%d\n", d[s.size( )][r.size( )] );
    vs ans;
    int n = s.size( );
    int m = r.size( );
    while( n || m ) {
        if( m && d[n][m - 1] + 1 == d[n][m] ) {
            sprintf( sbuf, "INSERT %d %c", m, r[m - 1] );
            ans.pb( sbuf );
            -- m;
        }
        else if( n && d[n - 1][m] + 1 == d[n][m] ) {
            sprintf( sbuf, "DELETE %d", n + is[n][m] );
            ans.pb( sbuf );
            -- n;
        }
        else if( n && m && d[n - 1][m - 1] + 1 == d[n][m] ) {
            sprintf( sbuf, "REPLACE %d %c", n + is[n][m], r[m - 1] );
            ans.pb( sbuf );
            -- n; -- m;
        } else { -- n; -- m; }
    }
    reverse( all( ans ) );
    outl( all( ans ) );

    return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

string a,b;

int    dp[1111][1111];
char from[1111][1111];

int main() {
	//freopen("input.txt", "r", stdin);

	cin >> a >> b;
	a = " " + a;
	b = " " + b;

	for (int i=0; i<a.size(); i++) {
		dp[0][i] = i;
		from[0][i] = 3;
	}

	for (int i=0; i<b.size(); i++) {
		dp[i][0] = i;
		from[i][0] = 2;
	}

	for (int i=1; i<b.size(); i++) {
		for (int u=1; u<a.size(); u++) {
			if (b[i] == a[u]) {
				dp[i][u] = dp[i-1][u-1];
				from[i][u] = 0;
			} else {
				dp[i][u] = dp[i-1][u-1] + 1;
				from[i][u] = 1;
			}

			if (dp[i-1][u] + 1 < dp[i][u]) {
				dp[i][u] = dp[i-1][u] + 1;
				from[i][u] = 2;
			}

			if (dp[i][u-1] + 1 < dp[i][u]) {
				dp[i][u] = dp[i][u-1] + 1;
				from[i][u] = 3;
			}
		}
	}

	cout << dp[b.size()-1][a.size()-1] << endl;

	vector<string> way;

	int curi = b.size() - 1;
	int curu = a.size() - 1;

	for(;;) {
		if (curi == 0 && curu == 0) break;
		if (from[curi][curu] == 1) {
			ostringstream ssout;
			ssout << "REPLACE ";
			ssout << curu << ' ';
			ssout << b[curi];
			string str = ssout.str();
			way.push_back(str);

			--curi;
			--curu;
		} else if (from[curi][curu] == 2) {
			ostringstream ssout;
			ssout << "INSERT ";
			ssout << curu+1 << ' ';
			ssout << b[curi];
			string str = ssout.str();
			way.push_back(str);

			--curi;
		} else if (from[curi][curu] == 3) {
			ostringstream ssout;
			ssout << "DELETE ";
			ssout << curu;
			string str = ssout.str();
			way.push_back(str);

			--curu;
		} else {
			--curi;
			--curu;
		}
	}

	for (int i=0; i<way.size(); i++)
		cout << way[i] << endl;

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:102400000,102400000")
#define eps 1e-9
#define LL long long
#define ULL unsigned long long
#define pii pair<int,LL>
#define MP make_pair
#define N (1000 + 20)
#define M (1000000 + 10)
#define inf 1e17
#define mod 1000000009
#define lson ll, md, ls
#define rson md+1, rr, rs
#define ls (i<<1)
#define rs (i<<1|1)
#define md (ll+rr>>1)

char s[N], t[N];
int dp[N][N];
int fa[N][N];

void update(int x, int y, int i, int j, int v) {
	if(dp[x][y] > dp[i][j] + v) {
		dp[x][y] = dp[i][j] + v;
		fa[x][y] = i * 10000 + j;
	}
}

void RE() {
	vector<int> vt;
	vt[0] = -1;
}

int add;
void output(int n, int m) {
	if(n == 0 && m == 0) return ;
	int fi = fa[n][m]/10000, fj = fa[n][m]%10000;
	output(fi, fj);
	if(fi+1 == n && fj + 1 == m) {
		if(dp[fi][fj] + 1== dp[n][m])
			printf("REPLACE %d %c\n", fi+1+add, t[fj]);
	}
	else if(fi + 1 == n) {
		printf("DELETE %d\n", fi+1 + add);
		--add;
	}
	else if(fj + 1 == m) {
		printf("INSERT %d %c\n", fi+1+add, t[fj]);
		++add;
	}
	else RE();
}

int main() {
	freopen("in.in", "r", stdin);
	scanf("%s", s);
	int n = strlen(s);
	scanf("%s", t);
	int m = strlen(t);
	memset(dp, 0x3f, sizeof dp);
	dp[0][0] = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			if(s[i] == t[j]) update(i+1, j+1, i, j, 0);
			else {update(i+1, j+1, i, j, 1);
			update(i, j+1, i, j, 1);
			update(i+1, j, i, j, 1);
			}
		}
	}
	printf("%d\n", dp[n][m]);
	output(n, m);

}


#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:102400000,102400000")
#define eps 1e-9
#define LL long long
#define ULL unsigned long long
#define pii pair<int,LL>
#define MP make_pair
#define N (1000 + 20)
#define M (1000000 + 10)
#define inf 1e17
#define mod 1000000009
#define lson ll, md, ls
#define rson md+1, rr, rs
#define ls (i<<1)
#define rs (i<<1|1)
#define md (ll+rr>>1)

char s[N], t[N];
int dp[N][N];
int fa[N][N];

void update(int x, int y, int i, int j, int v) {
	if(dp[x][y] > dp[i][j] + v) {
		dp[x][y] = dp[i][j] + v;
		fa[x][y] = i * 10000 + j;
	}
}

void RE() {
	vector<int> vt;
	vt[0] = -1;
}

int add;
void output(int n, int m) {
	if(n == 0 && m == 0) return ;
	int fi = fa[n][m]/10000, fj = fa[n][m]%10000;
	output(fi, fj);
	if(fi+1 == n && fj + 1 == m) {
		if(dp[fi][fj] + 1== dp[n][m])
			printf("REPLACE %d %c\n", fi+1+add, t[fj]);
	}
	else if(fi + 1 == n) {
		printf("DELETE %d\n", fi+1 + add);
		--add;
	}
	else if(fj + 1 == m) {
		printf("INSERT %d %c\n", fi+1+add, t[fj]);
		++add;
	}
	else RE();
}

int main() {
	scanf("%s", s);
	int n = strlen(s);
	scanf("%s", t);
	int m = strlen(t);
	memset(dp, 0x3f, sizeof dp);
	dp[0][0] = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			if(s[i] == t[j]) update(i+1, j+1, i, j, 0);
			else {update(i+1, j+1, i, j, 1);
			update(i, j+1, i, j, 1);
			update(i+1, j, i, j, 1);
			}
		}
	}
	printf("%d\n", dp[n][m]);
	output(n, m);

}


#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:102400000,102400000")
#define eps 1e-9
#define LL long long
#define ULL unsigned long long
#define pii pair<int,LL>
#define MP make_pair
#define N (1000 + 20)
#define M (1000000 + 10)
#define inf 1e17
#define mod 1000000009
#define lson ll, md, ls
#define rson md+1, rr, rs
#define ls (i<<1)
#define rs (i<<1|1)
#define md (ll+rr>>1)

char s[N], t[N];
int dp[N][N];
int fa[N][N];

void update(int x, int y, int i, int j, int v) {
	if(dp[x][y] > dp[i][j] + v) {
		dp[x][y] = dp[i][j] + v;
		fa[x][y] = i * 10000 + j;
	}
}

void RE() {
	vector<int> vt;
	vt[0] = -1;
}

int add;
void output(int n, int m) {
	if(n == 0 && m == 0) return ;
	int fi = fa[n][m]/10000, fj = fa[n][m]%10000;
	output(fi, fj);
	if(fi+1 == n && fj + 1 == m) {
		if(dp[fi][fj] + 1== dp[n][m])
			printf("REPLACE %d %c\n", fi+1+add, t[fj]);
	}
	else if(fi + 1 == n) {
		printf("DELETE %d\n", fi+1 + add);
		--add;
	}
	else if(fj + 1 == m) {
		printf("INSERT %d %c\n", fi+1+add, t[fj]);
		++add;
	}
}

int main() {
	scanf("%s", s);
	int n = strlen(s);
	scanf("%s", t);
	int m = strlen(t);
	memset(dp, 0x3f, sizeof dp);
	dp[0][0] = 0;
	for(int i = 0; i <= n; ++i) {
		for(int j = 0; j <= m; ++j) {
			if(s[i] == t[j]) update(i+1, j+1, i, j, 0);
			else update(i+1, j+1, i, j, 1);
			update(i, j+1, i, j, 1);
			update(i+1, j, i, j, 1);
		}
	}
	printf("%d\n", dp[n][m]);
	output(n, m);

}


#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <string>
#include <string.h>
#include <sstream>
#include <algorithm>
#include <map>
using namespace std;

#define mn(a,b,c) (min(min((a),(b)),(c)))

struct op{
	string name;
	int pos;
	char ch;
	op(){}
	op(string name, int pos, char ch):name(name), pos(pos), ch(ch){}
};
vector <op> v;

struct pt{
	int i, j;
	op t;
};
pt path[1010][1010];

int d[1010][1010];

int main()
{
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	char s[1010], t[1010];
	gets(s+1);
	gets(t+1);
	int n = strlen(s+1), m = strlen(t+1);

	for(int i=1; i<=n; i++){
		d[i][0] = i;
		path[i][0].i = i-1;
		path[i][0].j = 0;
		path[i][0].t = op("DELETE", 1, s[i]);
	}
	for(int j=1; j<=m; j++){
		d[0][j] = j;
		path[0][j].i = 0;
		path[0][j].j = j-1;
		path[0][j].t = op("INSERT", j, t[j]);
	}

	path[0][0].i = -1;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			op tt;
			d[i][j] = mn(d[i][j-1]+1, d[i-1][j]+1, d[i-1][j-1]+(s[i]!=t[j]));
			if(d[i][j-1]+1 <= min(d[i-1][j]+1, d[i-1][j-1]+(s[i]!=t[j]))){
				tt.name = "INSERT";
				tt.pos = j;
				tt.ch = t[j];
				path[i][j].i = i; path[i][j].j = j-1; path[i][j].t = tt;
			}
			else if(d[i-1][j]+1 <= min(d[i][j-1]+1, d[i-1][j-1]+(s[i]!=t[j]))){
				tt.name = "DELETE";
				tt.pos = j+1;
				path[i][j].i = i-1; path[i][j].j = j; path[i][j].t = tt;
			}
			else /*if(d[i-1][j-1]+(s[i]!=t[j]) <= min(d[i][j-1]+1, d[i-1][j]+1))*/{
				if(s[i]!=t[j]) {
					tt.name = "REPLACE";
					tt.pos = j;
					tt.ch = t[j];
				}
				path[i][j].i = i-1; path[i][j].j = j-1; path[i][j].t = tt;
			}
		}
	}

	printf("%d\n", d[n][m]);
	{
		int i = n, j = m;
		while(path[i][j].i != -1){
			v.push_back(path[i][j].t);
			int ii=i, jj=j;
			i=path[ii][jj].i;
			j=path[ii][jj].j;
		}
	}

	for(int i=(int)(v.size()-1); i>=0; i--){
		if (v[i].name == "") continue;
		if(v[i].name == "DELETE")
			cout<<"DELETE"<<' '<<v[i].pos;
		else
			cout<<v[i].name<<' '<<v[i].pos<<' '<<v[i].ch;
		cout<<'\n';
	}

	return 0;
}


#pragma comment(linker, "/STACK:268435456")
	#include <stdio.h>
#include<iostream>
#include<cstdio>

#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>

#include<iomanip>
#include<memory.h>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<cmath>
#include<cassert>
#include <sstream>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i < (int)(n); ++i)
#define nfor(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define correct(x, y, n, m) (0 <= x && x < n && 0 <= y && y < m)
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)(v.size())
#define hash archash
#define next arcnext
#define link arclink
#define y0 arcy0
#define y1 arcy1
#define log2 arclog2

template<typename T> inline T abs(T a){ return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a){ return a * a; }
template<class T> T gcd(T a, T b) { return a ? gcd (b % a, a) : b; }
template<class T> T lcm(T a, T b) { return a / gcd (a, b) * b; }
template<class T> T sign(T a) { return a > 0 ? 1 : (a < 0 ? -1 : 0); }

typedef long long li;
typedef unsigned long long uli;
typedef long double ld;
typedef pair <int, int> pt;
typedef vector <int> vi;
typedef vector <vector <int> > vvi;
typedef vector <pair <int, int> > vpt;

const int dx[] = {-1, 0, 1,  0};
const int dy[] = { 0, 1, 0, -1};
const int dxK[] = {-1, -1, 0, 1, 1,  1,  0, -1};
const int dyK[] = { 0,  1, 1, 1, 0, -1, -1, -1};
const int dxKn[] = {-2, -1, 1, 2,  2,  1, -1, -2};
const int dyKn[] = { 1,  2, 2, 1, -1, -2, -2, -1};

const int N = 1005;
const int M = int(3e2) + 9;
const int LOGN = 21;
const int SQN = 350;
const int MOD = int(1e9) + 7;
const int INF = int(1e9) + 100;
const li INF64 = 2e18;
const ld PI = ld(3.1415926535897932384626433832795);
const ld e = ld(2.7182818284590452353602874713527);
const ld EPS = 1e-9;

string a, b;

int dp[N][N];
char to[N][N];

int calc(int posa, int posb){
	int &res = dp[posa][posb];
	if(res != -1)
		return res;

	res = INF;
	if(posa == sz(a) && posb == sz(b))
		return res = 0;

	if(posa < sz(a) && posb < sz(b) && a[posa] == b[posb]){
		if(res > calc(posa + 1, posb + 1)){
			res = calc(posa + 1, posb + 1);
			to[posa][posb] = '!';
		}
	}

	if(posa < sz(a) && posb < sz(b)){
		if(res > calc(posa + 1, posb + 1) + 1){
			res = calc(posa + 1, posb + 1) + 1;
			to[posa][posb] = 'R';
		}
	}

	if(posa < sz(a)){
		if(res > calc(posa + 1, posb) + 1){
			res = calc(posa + 1, posb) + 1;
			to[posa][posb] = 'D';
		}
	}

	if(posb < sz(b)){
		if(res > calc(posa, posb + 1) + 1){
			res = calc(posa, posb + 1) + 1;
			to[posa][posb] = 'I';
		}
	}

	return res;
}

void solve(){
	cin >> a >> b;
	memset(dp, -1, sizeof dp);

	cout << calc(0, 0) << endl;

	pt pos = mp(0, 0);
	int bal = 0;
	while(!(pos.x == sz(a) && pos.y == sz(b))){
		if(to[pos.x][pos.y] == '!'){
			++pos.x, ++pos.y;
		}
		if(to[pos.x][pos.y] == 'R'){
			cout << "REPLACE " << pos.x + bal + 1 << ' ' << b[pos.y] << endl;
			++pos.x, ++pos.y;
		}
		if(to[pos.x][pos.y] == 'D'){
			cout << "DELETE " << pos.x + bal + 1 << endl;
			--bal;
			++pos.x;
		}
		if(to[pos.x][pos.y] == 'I'){
			cout << "INSERT " << pos.x + bal + 1 << ' ' << b[pos.y] << endl;
			++bal;
			++pos.y;
		}
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	srand(time(NULL));
	cout << setprecision(5) << fixed;
	cerr << setprecision(5) << fixed;

	solve();

	return 0;

}


#include <iostream>
#include <string>
using namespace std;
string s1 , s2;
int dp[1000+1][1000+1];
int path[1000+1][1000+1];
const int inf=100500;
int solve(int x,int y)
{
	if(dp[x][y]!=inf)
		return dp[x][y];
	int minA=inf;
	if(x<s1.size() && y<s2.size() && s1[x]==s2[y])
		if(solve(x+1,y+1) < dp[x][y])
		{
			dp[x][y]=solve(x+1,y+1);
			path[x][y]=1;
		}
	if(x<s1.size() && y<s2.size())
		if(solve(x+1,y+1)+1<dp[x][y])
		{
			dp[x][y]=solve(x+1,y+1)+1;
			path[x][y]=2;
		}
	if(y<s2.size())
		if(solve(x,y+1)+1<dp[x][y])
		{
			dp[x][y]=solve(x,y+1)+1;
			path[x][y]=3;
		}
	if(x<s1.size())
		if(solve(x+1,y)+1<dp[x][y])
		{
			dp[x][y]=solve(x+1,y)+1;
			path[x][y]=4;
		}
	return dp[x][y];
}
int main()
{
	//freopen("input.txt","r",stdin);
	cin>>s2>>s1;
	for(int i=0;i<=s1.size();i++)
		for(int j=0;j<=s2.size();j++)
			dp[i][j]=inf;
	dp[s1.size()][s2.size()]=0;
	cout<<solve(0,0)<<endl;
	int x=0,y=0,d=0;
	while( !(x==s1.size() && y==s2.size() ))
	{

		switch(path[x][y])
		{
			case 1:
				x=x+1;
				y=y+1;
				break;
			case 2:
				cout<<"REPLACE "<<y+1+d<<" "<<s1[x]<<endl;
				x=x+1;
				y=y+1;
				break;
			case 3:
				cout<<"DELETE "<<y+1+d<<endl;
				y=y+1;
				d--;
				break;
			case 4:
				cout<<"INSERT "<<y+1+d<<" "<<s1[x]<<endl;
				x=x+1;
				d++;
				break;
		}

	}
	return 0;
}


#include <iostream>
#include <string>
using namespace std;
string s1 , s2;
int dp[1000+1][1000+1];
int path[1000+1][1000+1];
const int inf=100500;
int solve(int x,int y)
{
	if(dp[x][y]!=inf)
		return dp[x][y];
	int minA=inf;
	if(x<s1.size() && y<s2.size() && s1[x]==s2[y])
		if(solve(x+1,y+1) < dp[x][y])
		{
			dp[x][y]=solve(x+1,y+1);
			path[x][y]=1;
		}
	if(x<s1.size() && y<s2.size())
		if(solve(x+1,y+1)+1<dp[x][y])
		{
			dp[x][y]=solve(x+1,y+1)+1;
			path[x][y]=2;
		}
	if(y<s2.size())
		if(solve(x,y+1)+1<dp[x][y])
		{
			dp[x][y]=solve(x,y+1)+1;
			path[x][y]=3;
		}
	if(x<s1.size())
		if(solve(x+1,y)+1<dp[x][y])
		{
			dp[x][y]=solve(x+1,y)+1;
			path[x][y]=4;
		}
	return dp[x][y];
}
int main()
{
	//freopen("input.txt","r",stdin);
	cin>>s2>>s1;
	for(int i=0;i<=s1.size();i++)
		for(int j=0;j<=s2.size();j++)
			dp[i][j]=inf;
	dp[s1.size()][s2.size()]=0;
	cout<<solve(0,0)<<endl;
	int x=0,y=0;
	while( !(x==s1.size() && y==s2.size() ))
	{

		switch(path[x][y])
		{
			case 1:
				x=x+1;
				y=y+1;
				break;
			case 2:
				cout<<"REPLACE "<<y+1<<" "<<s1[x]<<endl;
				x=x+1;
				y=y+1;
				break;
			case 3:
				cout<<"DELETE "<<y+1<<endl;
				y=y+1;
				break;
			case 4:
				cout<<"INSERT "<<y+1<<" "<<s1[x]<<endl;
				x=x+1;
				break;
		}

	}
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#include <fstream>
using namespace std;
#define rp(i,n) for(int (i)=0;(i)<(n);++(i))
#define pb push_back
#define L(s) (int)s.size()
#define mp make_pair
#define pii pair<int,int>
#define x first
#define y second
#define inf 1000000000
#define VI vector<int>
#define ll long long
#define all(s) (s).begin(),(s).end()
#define C(u) memset((u),0,sizeof((u)))
string s,t;
int a[1111][1111];
int b[1111][1111];
int c[1111][1111];
vector<string> ans;
inline void add(string c,int p1,char p2)
{
	ostringstream oss;
	oss<<c<<" "<<p1;
	if (p2!='!')
		oss<<" "<<p2;
	ans.pb(oss.str());
}
int main()
{
	cin>>s;
	cin>>t;
	bool ok;
	ok=0;
	rp(i,L(t))
	{
		if (t[i]==s[0])
			ok=1;
		if (ok)
			a[0][i]=i;
		else
			a[0][i]=i+1;
	}
	ok=0;
	rp(j,L(s))
	{
		if (s[j]==t[0])
			ok=1;
		if (ok)
			a[j][0]=j;
		else
			a[j][0]=j+1;
	}
	rp(i,L(s))
		rp(j,L(t))
		if (i&&j)
		{
			int add=1;
			if (s[i]==t[j])
				add=0;
			if (a[i-1][j-1]+add<=a[i-1][j]+1&&a[i-1][j-1]+add<=a[i][j-1]+1)
			{
				b[i][j]=1;
				c[i][j]=1;
				a[i][j]=a[i-1][j-1]+add;
			}
			else
				if (a[i][j-1]+1<a[i-1][j]+1&&a[i][j-1]+1<=a[i-1][j-1]+add)
				{
					b[i][j]=0;
					c[i][j]=1;
					a[i][j]=a[i][j-1]+1;
				}
				else
				{
					b[i][j]=1;
					c[i][j]=0;
					a[i][j]=a[i-1][j]+1;
				}
		}
	int ci=L(s)-1,cj=L(t)-1;
	while(ci&&cj)
	{
		if (b[ci][cj]&&c[ci][cj])
		{
			if (s[ci]!=t[cj])
				add("REPLACE",ci+1,t[cj]);
		}
		else
			if (b[ci][cj])
				add("DELETE",ci+1,'!');
			else
				add("INSERT",cj+1,t[cj]);
		int nci=ci-b[ci][cj];
		int ncj=cj-c[ci][cj];
		ci=nci;
		cj=ncj;
	}
	if (cj)
	{
		ok=0;
		while(cj)
		{
			if (s[ci]==t[cj])
				ok=1;
			else
				if (!ok)
					add("INSERT",2,t[cj]);
				else
					add("INSERT",1,t[cj]);
			--cj;
		}
		if (!ok)
		{
			if (a[0][0])
				add("REPLACE",1,t[0]);
		}
		else
			add("INSERT",1,t[0]);
	}
	else
		if (cj)
		{
			ok=0;
			while(ci)
			{
				if (s[ci]==t[cj])
					ok=1;
				else
					if (!ok)
						add("DELETE",2,'!');
					else
						add("DELETE",1,'!');
				--ci;
			}
			if (!ok)
			{
				if (a[0][0])
					add("REPLACE",1,t[0]);
			}
			else
				add("DELETE",1,'!');
		}
		else
	if (a[0][0])
		add("REPLACE",1,t[0]);
	cout<<a[L(s)-1][L(t)-1]<<endl;
	rp(i,L(ans))
		cout<<ans[i]<<endl;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#include <fstream>
using namespace std;
#define rp(i,n) for(int (i)=0;(i)<(n);++(i))
#define pb push_back
#define L(s) (int)s.size()
#define mp make_pair
#define pii pair<int,int>
#define x first
#define y second
#define inf 1000000000
#define VI vector<int>
#define ll long long
#define all(s) (s).begin(),(s).end()
#define C(u) memset((u),0,sizeof((u)))
string s,t;
int a[1111][1111];
vector<string> ans;
inline void add(string c,int p1,char p2)
{
        ostringstream oss;
        oss<<c<<" "<<p1;
        if (p2!='!')
                oss<<" "<<p2;
        ans.pb(oss.str());
}
int main()
{
        cin>>s;
        cin>>t;
		rp(i,L(s)+1)
			a[i][0]=i;
		rp(j,L(t)+1)
			a[0][j]=j;
		rp(i,L(s)+1)
			rp(j,L(t)+1)
			if (i&&j)
				a[i][j]=min(a[i-1][j-1]+((s[i-1]==t[j-1])?(0):(1)),min(a[i][j-1]+1,a[i-1][j]+1));
		int ci=L(s);
		int cj=L(t);
		while(ci&&cj)
		{
			int val=min(a[ci-1][cj-1]+((s[ci-1]==t[cj-1])?(0):(1)),min(a[ci][cj-1]+1,a[ci-1][cj]+1));
			if (a[ci][cj-1]+1==val)
				add("INSERT",ci+1,t[--cj]);
			else
				if (a[ci-1][cj]+1==val)
					add("DELETE",ci--,'!');
				else
				{
					if (s[ci-1]!=t[cj-1])
						add("REPLACE",ci,t[cj-1]);
					--ci;--cj;
				}
		}
		while(ci)
			add("DELETE",ci--,'!');
		while(cj)
			add("INSERT",1,t[cj--]);
        cout<<a[L(s)][L(t)]<<endl;
        rp(i,L(ans))
                cout<<ans[i]<<endl;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#include <fstream>
using namespace std;
#define rp(i,n) for(int (i)=0;(i)<(n);++(i))
#define pb push_back
#define L(s) (int)s.size()
#define mp make_pair
#define pii pair<int,int>
#define x first
#define y second
#define inf 1000000000
#define VI vector<int>
#define ll long long
#define all(s) (s).begin(),(s).end()
#define C(u) memset((u),0,sizeof((u)))
string s,t;
int a[1111][1111];
int b[1111][1111];
int c[1111][1111];
vector<string> ans;
inline void add(string c,int p1,char p2)
{
	ostringstream oss;
	oss<<c<<" "<<p1;
	if (p2!='!')
		oss<<" "<<p2;
	ans.pb(oss.str());
}
int main()
{
	cin>>s;
	cin>>t;
	bool ok;
	ok=0;
	rp(i,L(t))
	{
		if (t[i]==s[0])
			ok=1;
		if (ok)
			a[0][i]=i;
		else
			a[0][i]=i+1;
	}
	ok=0;
	rp(j,L(s))
	{
		if (s[j]==t[0])
			ok=1;
		if (ok)
			a[j][0]=j;
		else
			a[j][0]=j+1;
	}
	rp(i,L(s))
		rp(j,L(t))
		if (i&&j)
		{
			int add=1;
			if (s[i]==t[j])
				add=0;
			if (a[i-1][j-1]+add<=a[i-1][j]+1&&a[i-1][j-1]+add<=a[i][j-1]+1)
			{
				b[i][j]=1;
				c[i][j]=1;
				a[i][j]=a[i-1][j-1]+add;
			}
			else
				if (a[i][j-1]+1<a[i-1][j]+1&&a[i][j-1]+1<=a[i-1][j-1]+add)
				{
					b[i][j]=0;
					c[i][j]=1;
					a[i][j]=a[i][j-1]+1;
				}
				else
				{
					b[i][j]=1;
					c[i][j]=0;
					a[i][j]=a[i-1][j]+1;
				}
		}
	int ci=L(s)-1,cj=L(t)-1;
	while(ci&&cj)
	{
		if (b[ci][cj]&&c[ci][cj])
		{
			if (s[ci]!=t[cj])
				add("REPLACE",ci+1,t[cj]);
		}
		else
			if (b[ci][cj])
				add("DELETE",ci+1,'!');
			else
				add("INSERT",cj+1,t[cj]);
		int nci=ci-b[ci][cj];
		int ncj=cj-c[ci][cj];
		ci=nci;
		cj=ncj;
	}
	if (cj)
	{
		ok=0;
		while(cj)
		{
			if (s[ci]==t[cj])
				ok=1;
			else
				if (!ok)
					add("INSERT",2,t[cj]);
				else
					add("INSERT",1,t[cj]);
			--cj;
		}
		if (!ok)
		{
			if (a[0][0])
				add("REPLACE",1,t[0]);
		}
		else
			add("INSERT",1,t[0]);
	}
	else
		if (ci)
		{
			ok=0;
			while(ci)
			{
				if (s[ci]==t[cj])
					ok=1;
				else
					if (!ok)
						add("DELETE",2,'!');
					else
						add("DELETE",1,'!');
				--ci;
			}
			if (!ok)
			{
				if (a[0][0])
					add("REPLACE",1,t[0]);
			}
			else
				add("DELETE",1,'!');
		}
		else
	if (a[0][0])
		add("REPLACE",1,t[0]);
	cout<<a[L(s)-1][L(t)-1]<<endl;
	rp(i,L(ans))
		cout<<ans[i]<<endl;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#include <fstream>
using namespace std;
#define rp(i,n) for(int (i)=0;(i)<(n);++(i))
#define pb push_back
#define L(s) (int)s.size()
#define mp make_pair
#define pii pair<int,int>
#define x first
#define y second
#define inf 1000000000
#define VI vector<int>
#define ll long long
#define all(s) (s).begin(),(s).end()
#define C(u) memset((u),0,sizeof((u)))
string s,t;
int a[1111][1111];
vector<string> ans;
inline void add(string c,int p1,char p2)
{
        ostringstream oss;
        oss<<c<<" "<<p1;
        if (p2!='!')
                oss<<" "<<p2;
        ans.pb(oss.str());
}
int main()
{
        cin>>s;
        cin>>t;
		rp(i,L(s)+1)
			a[i][0]=i;
		rp(j,L(t)+1)
			a[0][j]=j;
		rp(i,L(s)+1)
			rp(j,L(t)+1)
			if (i&&j)
				a[i][j]=min(a[i-1][j-1]+((s[i-1]==t[j-1])?(0):(1)),min(a[i][j-1]+1,a[i-1][j]+1));
		int ci=L(s);
		int cj=L(t);
		while(ci&&cj)
		{
			int val=min(a[ci-1][cj-1]+((s[ci-1]==t[cj-1])?(0):(1)),min(a[ci][cj-1]+1,a[ci-1][cj]+1));
			if (a[ci][cj-1]+1==val)
				add("INSERT",ci+1,t[--cj]);
			else
				if (a[ci-1][cj]+1==val)
					add("DELETE",ci--,'!');
				else
				{
					if (s[ci-1]!=t[cj-1])
						add("REPLACE",ci,t[cj-1]);
					--ci;--cj;
				}
		}
		while(ci)
			add("DELETE",ci--,'!');
		while(cj)
			add("INSERT",1,t[--cj]);
        cout<<a[L(s)][L(t)]<<endl;
        rp(i,L(ans))
                cout<<ans[i]<<endl;
}