#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int d[1002][1002];
char ok[1002][1002];
string tostr(int i)
{
	string res="";
	while (i)
	{
		res+=(char)(i%10+'0');
		i/=10;
	}
	reverse(res.begin(),res.end());
	return res;
}
int main()
{
//	freopen("in.in","r",stdin);
	string s1,s2;
	cin>>s1>>s2;
	int n=s1.size(),m=s2.size();
	s1='$'+s1;
	s2='$'+s2;
	for (int i=0;i<=n;i++)
	{
		d[i][0]=i;
		ok[i][0]=0;
	}
	for (int i=0;i<=m;i++)
	{
		d[0][i]=i;
		ok[0][i]=1;
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			d[i][j]=10000*10000;
			if (d[i-1][j]+1<=min(d[i][j-1]+1,d[i-1][j-1]+(s1[i]!=s2[j])))
			{
				d[i][j]=d[i-1][j]+1;
				ok[i][j]=0;
				continue;
			}
			if (d[i][j-1]+1<=min(d[i-1][j]+1,d[i-1][j-1]+(s1[i]!=s2[j])))
			{
				d[i][j]=d[i][j-1]+1;
				ok[i][j]=1;
				continue;
			}
			if (d[i-1][j-1]+(s1[i]!=s2[j])<=min(d[i][j-1]+1,d[i-1][j]+1))
			{
				d[i][j]=d[i-1][j-1]+(s1[i]!=s2[j]);
				ok[i][j]=2;
				continue;
			}
		}
	}
	cout<<d[n][m]<<endl;
	int I=n,J=m;
	int s=d[n][m];
	vector<pair<int,pair<int,int> > > answer;
	while (s)
	{
		if (ok[I][J]==0&&I)
		{
			if (d[I][J]!=d[I-1][J])
			{
				answer.push_back(make_pair(0,make_pair(I-1,J)));
				s--;
			}
			I--;
		}
		if (ok[I][J]==1&&J)
		{
			if (d[I][J]!=d[I][J-1])
			{
				answer.push_back(make_pair(1,make_pair(I,J-1)));
				s--;
			}
			J--;
		}
		if (ok[I][J]==2)
		{
			if (d[I][J]!=d[I-1][J-1])
			{
				answer.push_back(make_pair(2,make_pair(I-1,J-1)));
				s--;
			}
			I--;
			J--;
		}
	}
	reverse(answer.begin(),answer.end());
	for (int i=0;i<answer.size();i++)
	{
		if (answer[i].first==0)
		{
			cout<<"DELETE "<<answer[i].second.second+1<<endl;
		}
		if (answer[i].first==1)
		{
			cout<<"INSERT "<<answer[i].second.second+1<<' '<<s2[answer[i].second.second+1]<<endl;
		}
		if (answer[i].first==2)
		{
			cout<<"REPLACE "<<answer[i].second.second+1<<' '<<s2[answer[i].second.second+1]<<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>
#include <string.h>
using namespace std;

string s,t;
int best[1003][1003];

int dp(int i1, int i2)
{
	if(i1 >= s.size() || i2 >= t.size())
		if(i1 == s.size() && i2 == t.size())
			return 0;
		else
			return 1e9;

	if(best[i1][i2]!=-1)
		return best[i1][i2];

	int res=1e9;
	if(s[i1]==t[i2])
		res=dp(i1+1,i2+1);

	res=min(res,dp(i1,i2+1)+1);
	res=min(res,dp(i1+1,i2+1)+1);
	res=min(res,dp(i1+1,i2)+1);

	return best[i1][i2]=res;
}

void path(int i1, int i2, int rem, int ni1, int ni2)
{
	if(i1 >= s.size() || i2 >= t.size())
		if(i1 == s.size() && i2 == t.size())
			return ;
		else
			return ;

	int res=1e9;
	if(best[i1][i2]==rem && s[i1]==t[i2])
		path(i1+1,i2+1,rem, ni1+1,ni2+1);
	else if(dp(i1,i2+1)+1 == rem)
	{
		cout<<"INSERT "<<ni1+1<<" "<<t[ni2]<<endl;
		path(i1,i2+1,rem-1, ni1+1,ni2+1);
	}
	else if(dp(i1+1,i2+1)+1 == rem)
	{
		cout<<"REPLACE "<<ni1+1<<" "<<t[ni2]<<endl;
		path(i1+1,i2+1,rem-1, ni1+1,ni2+1);
	}
	else if(dp(i1+1,i2)+1 == rem)
	{
		cout<<"DELETE "<<ni1<<endl;
		path(i1+1,i2,rem-1,ni1,ni2);
	}
}

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

	cin>>s>>t;
	memset(best,-1, sizeof best);
	int res=dp(0,0);

	cout<<res<<endl;
	path(0,0,res,0,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>
#include <string.h>
using namespace std;

string s,t;
int best[1003][1003];

int dp(int i1, int i2)
{
	if(i1 == s.size() && i2 == t.size()) return 0;
	if(i1 > s.size() || i2 > t.size())  return (int)1e9;
	//if(i1==s.size()) return t.size()-i2;
	//if(i2==t.size()) return s.size()-i1;

	if(best[i1][i2]!=-1)
		return best[i1][i2];

	int res=1e9;
	if(i1 < s.size() && i2 < t.size() && s[i1]==t[i2])
		return best[i1][i2]=dp(i1+1,i2+1);

	res=min(res,dp(i1,i2+1)+1);
	res=min(res,dp(i1+1,i2+1)+1);
	res=min(res,dp(i1+1,i2)+1);

	return best[i1][i2]=res;
}

string out="";

void path(int i1, int i2, int rem, int ni1, int ni2)
{
	if(i1 == s.size() && i2 == t.size()) return ;
	if(i1 > s.size() || i2 > t.size())  return ;

	int res=1e9;
	if(i1 < s.size() && i2 < t.size() && best[i1][i2]==rem && s[i1]==t[i2])
	{
		out+=t[i2];
		path(i1+1,i2+1,rem, ni1+1,ni2+1);
	}
	else if(dp(i1,i2+1)+1 == rem)
	{
		cout<<"INSERT "<<ni1+1<<" "<<t[ni2]<<endl;
		out+=t[ni2];
		path(i1,i2+1,rem-1, ni1+1,ni2+1);
	}
	else if(dp(i1+1,i2+1)+1 == rem)
	{
		cout<<"REPLACE "<<ni1+1<<" "<<t[ni2]<<endl;
		out+=t[ni2];
		path(i1+1,i2+1,rem-1, ni1+1,ni2+1);
	}
	else if(dp(i1+1,i2)+1 == rem)
	{
		cout<<"DELETE "<<ni1+1<<endl;
		path(i1+1,i2,rem-1,ni1,ni2);
	}
}

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

	cin>>s>>t;
	memset(best,-1, sizeof best);
	int res=dp(0,0);

	cout<<res<<endl;
	path(0,0,res,0,0);
	for(int i=0;  i < t.size(); i++)
		if(t[i]!=out[i])
			cout<<"false";

	if(out.size()!=t.size())
		cout<<"false";
}


#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>
#include <string.h>
using namespace std;

string s,t;
int best[1003][1003];

int dp(int i1, int i2)
{
	if(i1 >= s.size() || i2 >= t.size())
		if(i1 == s.size() && i2 == t.size())
			return 0;
		else
			return 1e9;

	if(best[i1][i2]!=-1)
		return best[i1][i2];

	int res=1e9;
	if(s[i1]==t[i2])
		res=dp(i1+1,i2+1);

	res=min(res,dp(i1,i2+1)+1);
	res=min(res,dp(i1+1,i2+1)+1);
	res=min(res,dp(i1+1,i2)+1);

	return best[i1][i2]=res;
}

void path(int i1, int i2, int rem, int ni1, int ni2)
{
	if(i1 >= s.size() || i2 >= t.size())
		if(i1 == s.size() && i2 == t.size())
			return ;
		else
			return ;

	int res=1e9;
	if(best[i1][i2]==rem && s[i1]==t[i2])
		path(i1+1,i2+1,rem, ni1+1,ni2+1);
	else if(dp(i1,i2+1)+1 == rem)
	{
		cout<<"INSERT "<<ni1+1<<" "<<t[ni2]<<endl;
		path(i1,i2+1,rem-1, ni1+1,ni2+1);
	}
	else if(dp(i1+1,i2+1)+1 == rem)
	{
		cout<<"REPLACE "<<ni1+1<<" "<<t[ni2]<<endl;
		path(i1+1,i2+1,rem-1, ni1+1,ni2+1);
	}
	else if(dp(i1+1,i2)+1 == rem)
	{
		cout<<"DELETE "<<ni1+1<<endl;
		path(i1+1,i2,rem-1,ni1,ni2);
	}
}

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

	cin>>s>>t;
	memset(best,-1, sizeof best);
	int res=dp(0,0);

	cout<<res<<endl;
	path(0,0,res,0,0);
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <sstream>
#include <numeric>
#include <functional>
#include <set>
#include <cmath>
#include <stack>
#include <fstream>
#include <cassert>
#ifdef HOME_PC
#include <ctime>
#endif
using namespace std;

#pragma comment(linker,"/stack:16000000")
#pragma warning (disable : 4996)

#define ALL(v) v.begin(),v.end()
#define SZ(v) (int)v.size()
#define mset(A,x) memset((A),(x),sizeof(A))
#define FOR(i,start,N) for(int i=(start);i<(N);++i)
#define FORSZ(i,start,v) FOR(i,start,SZ(v))
#define REPSZ(i,v) FORSZ(i,0,v)
#define FORE(i,start,N) FOR(i,start,N+1)
#define make_unique(v) v.resize(unique(ALL(v))-v.begin())
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define adebug(A,N) FOR(i,0,N) cout<<#A<<"["<<i<<"] = "<<A[i]<<endl;
#define adebug2d(a,n,m) FOR(i,0,n) { FOR(j,0,m) { cout<<a[i][j]<<" ";} cout<<endl;}
#define vdebug(v) REPSZ(i,v) cout<<#v<<"["<<i<<"] = "<<v[i]<<endl;
#define selfx(x,f,a) x = f(x,a)
#define sqr(x) ((x)*(x))

typedef pair<int,int> pii;
typedef long long i64;
typedef vector<int> VI; typedef vector< vector<int> > VVI;
typedef vector<string> VS;

const int inf = 1<<25;
const double eps = 1e-9;

map<string,int> cost;

enum ACTION {NOTHING, DELETE, INSERT, REPLACE };

string itos(int x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

int main(int argc, char* argv[])
{
#ifdef HOME_PC
    //freopen ("input.txt","r",stdin);
    //freopen ("in.txt","r",stdin);
    //freopen ("output.txt","w",stdout);
#endif

    const int MAXN = 1<<10;

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

    int dp[MAXN][MAXN];
    ACTION act[MAXN][MAXN];

    FOR(i,0,MAXN)
    {
        dp[0][i] = dp[i][0] = i;
        act[0][i] = INSERT;
        act[i][0] = DELETE;
    }

    FORE(i,1,s.length())
        FORE(j,1,t.length())
    {
        dp[i][j] = min(dp[i-1][j],dp[i][j-1])+1;
        dp[i][j] = min(dp[i][j], dp[i-1][j-1]+(s[i-1] != t[j-1]));
        if( dp[i][j] ==  dp[i-1][j] + 1)
        {
            act[i][j] = DELETE;
        }
        else
            if( dp[i][j] == dp[i][j-1] + 1)
            {
                act[i][j] = INSERT;
            }
            else
            {
                act[i][j] = (s[i-1] == t[j-1] ? NOTHING : REPLACE);
            }
    }

    int ci = s.length(), cj = t.length();

    vector<string> actions;

    while(ci > 0 || cj > 0)
    {
        switch(act[ci][cj])
        {
        case NOTHING:
            --ci, --cj;
            break;
        case REPLACE:
            actions.push_back("REPLACE "+string(itos(cj))+" "+t[cj-1]);
            --ci, --cj;
            break;
        case DELETE:
            actions.push_back("DELETE "+string(itos(cj+1)));
            --ci;
            break;
        case INSERT:
            actions.push_back("INSERT "+string(itos(cj))+ " " + t[cj-1]);
            --cj;
            break;
        }
    }

    cout<<dp[s.length()][t.length()]<<endl;
    reverse(ALL(actions));
    REPSZ(i,actions)
        cout<<actions[i]<<endl;

#ifdef HOME_PC
        cerr<<endl<<"Execution time = "<<clock()<<" ms"<<endl;
#endif
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <sstream>
#include <numeric>
#include <functional>
#include <set>
#include <cmath>
#include <stack>
#include <fstream>
#include <cassert>
#ifdef HOME_PC
#include <ctime>
#endif
using namespace std;

#pragma comment(linker,"/stack:16000000")
#pragma warning (disable : 4996)

#define ALL(v) v.begin(),v.end()
#define SZ(v) (int)v.size()
#define mset(A,x) memset((A),(x),sizeof(A))
#define FOR(i,start,N) for(int i=(start);i<(N);++i)
#define FORSZ(i,start,v) FOR(i,start,SZ(v))
#define REPSZ(i,v) FORSZ(i,0,v)
#define FORE(i,start,N) FOR(i,start,N+1)
#define make_unique(v) v.resize(unique(ALL(v))-v.begin())
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define adebug(A,N) FOR(i,0,N) cout<<#A<<"["<<i<<"] = "<<A[i]<<endl;
#define adebug2d(a,n,m) FOR(i,0,n) { FOR(j,0,m) { cout<<a[i][j]<<" ";} cout<<endl;}
#define vdebug(v) REPSZ(i,v) cout<<#v<<"["<<i<<"] = "<<v[i]<<endl;
#define selfx(x,f,a) x = f(x,a)
#define sqr(x) ((x)*(x))

typedef pair<int,int> pii;
typedef long long i64;
typedef vector<int> VI; typedef vector< vector<int> > VVI;
typedef vector<string> VS;

const int inf = 1<<25;
const double eps = 1e-9;

map<string,int> cost;

enum ACTION {NOTHING, DELETE, INSERT, REPLACE };

string itos(int x)
{
	stringstream ss;
	ss<<x;
	return ss.str();
}

int main(int argc, char* argv[])
{
#ifdef HOME_PC
	//freopen ("input.txt","r",stdin);
	//freopen ("in.txt","r",stdin);
	//freopen ("output.txt","w",stdout);
#endif

	const int MAXN = 1<<10;

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

	int dp[MAXN][MAXN];
	ACTION act[MAXN][MAXN];

	FOR(i,0,MAXN)
		dp[0][i] = dp[i][0] = i;

	FORE(i,1,s.length())
		FORE(j,1,t.length())
	{
		dp[i][j] = min(dp[i-1][j],dp[i][j-1])+1;
		dp[i][j] = min(dp[i][j], dp[i-1][j-1]+(s[i-1] != t[j-1]));
		if( dp[i][j] ==  dp[i-1][j] + 1)
		{
			act[i][j] = DELETE;
		}
		else
			if( dp[i][j] == dp[i][j-1] + 1)
			{
				act[i][j] = INSERT;
			}
			else
			{
				act[i][j] = (s[i-1] == t[j-1] ? NOTHING : REPLACE);
			}
	}

	int ci = s.length(), cj = t.length();

	vector<string> actions;

	while(ci > 0 || cj > 0)
	{
		switch(act[ci][cj])
		{
		case NOTHING:
			--ci, --cj;
			break;
		case REPLACE:
			actions.push_back("REPLACE "+string(itos(cj))+" "+t[cj-1]);
			--ci, --cj;
			break;
		case DELETE:
			actions.push_back("DELETE "+string(itos(cj+1)));
			--ci;
			break;
		case INSERT:
			actions.push_back("INSERT "+string(itos(cj))+ " " + t[cj-1]);
			--cj;
			break;
		}
	}

	cout<<dp[s.length()][t.length()]<<endl;
	reverse(ALL(actions));
	REPSZ(i,actions)
		cout<<actions[i]<<endl;

#ifdef HOME_PC
		cerr<<endl<<"Execution time = "<<clock()<<" ms"<<endl;
#endif
	return 0;
}


#include<iostream>
#include<string>
using namespace std;
int dp[1001][1001], p[1001][1001];
string s, t;
int solve(int i, int j){
    if(i == s.length() && j == t.length())
        return 0;
    int &res = dp[i][j];
    if(res != -1)
        return res;
    res = 10000;
    if(i < s.length() && j < t.length()){
        if(s[i] == t[j])
            res = solve(i + 1, j + 1);
        else
            res = solve(i + 1, j + 1) + 1;
        p[i][j] = 0;
    }
    if(i < s.length()){
        int l = solve(i + 1, j) + 1;
        if(l < res){
            res = l;
            p[i][j] = 1;
        }
    }
    if(j < t.length()){
        int l = solve(i, j + 1) + 1;
        if(l < res){
            res = l;
            p[i][j] = 2;
        }
    }
    return res;
}
void go(int i, int j, int k){
    if(i == s.length() && j == t.length())
        return;
    if(p[i][j] == 0){
        if(s[i] != t[j])
            printf("REPLACE %d %c\n", k, t[j]);
        go(i + 1, j + 1, k + 1);
    }
    if(p[i][j] == 1){
        printf("DELETE %d\n", k);
        go(i + 1, j, k);
    }
    if(p[i][j] == 2){
        printf("INSERT %d %c\n", k, t[j]);
        go(i, j + 1, k + 1);
    }
}
int main(){
    cin >> s >> t;
    memset(dp, -1, sizeof dp);
    int l = solve(0, 0);
    cout << l << endl;
    go(0, 0, 1);
    return 0;
}


#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

int dp[1005][1005];
int pr[1005][1005];

string init, target;

char s[1005];

int main(void)
{
    scanf("%s", &s);
    init = (string) s;
    scanf("%s", &s);
    target = (string) s;

    int n = init.length();
    int m = target.length();
    for (int i = 0; i <= n; i++)
        dp[i][0] = i, pr[i][0] = 2;

    for (int i = 0; i <= m; i++)
        dp[0][i] = i, pr[0][i] = 1;

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            if (init[i-1] == target[j-1])
            {
                dp[i][j] = dp[i-1][j-1];
                pr[i][j] = 3;
            }
            else
            {
                if (dp[i-1][j-1] <= dp[i-1][j] && dp[i-1][j-1] <= dp[i][j-1])
                {
                    dp[i][j] = dp[i-1][j-1] + 1;
                    pr[i][j] = 3;
                }
                else
                    if (dp[i-1][j] <= dp[i-1][j-1] && dp[i-1][j] <= dp[i][j-1])
                    {
                        dp[i][j] = dp[i-1][j] + 1;
                        pr[i][j] = 2;
                    }
                    else
                        if (dp[i][j-1] <= dp[i-1][j-1] && dp[i][j-1] <= dp[i-1][j])
                        {
                            dp[i][j] = dp[i][j-1] + 1;
                            pr[i][j] = 1;
                        }
            }
        }

    printf("%d\n", dp[n][m]);

    int x = n, y = m;
    while (x != 0 || y != 0)
    {
        if (pr[x][y] == 1)
        {
            printf("INSERT %d %c\n", x + 1, target[y-1]);
            y--;
        }
        else
            if (pr[x][y] == 2)
            {
                printf("DELETE %d\n", x);
                x--;
            }
            else
            {
                if (init[x-1] != target[y-1])
                {
                    printf("REPLACE %d %c\n", x, target[y-1]);
                }

                x--,y--;
            }
    }
    return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

#if !defined(ONLINE_JUDGE)
#include <windows.h>
class StopWatch
{
    DWORD tickStart;
    std::string name;
public:
    StopWatch(const char *str = NULL): tickStart(GetTickCount()), name(str ? str : "Time") {}
    ~StopWatch() {std::cout << name << ": " << (GetTickCount() - tickStart) << " ms" << std::endl;}
};
#else //!defined(ONLINE_JUDGE)
class StopWatch {public: StopWatch(const char *) {} StopWatch() {}};
#endif //!defined(ONLINE_JUDGE)

// Types definition
//
typedef signed char                 int8;
typedef unsigned char               uint8;
typedef signed short                int16;
typedef unsigned short              uint16;
typedef signed long                 int32;
typedef unsigned long               uint32;
typedef signed long long            int64;
typedef unsigned long long          uint64;

typedef std::vector<size_t>         SizeTVector;
typedef std::set<size_t>            SizeTSet;
typedef std::multiset<size_t>       SizeTMultiset;

typedef std::vector<std::string>    StringVector;
typedef std::set<std::string>       StringSet;
typedef std::multiset<std::string>  StringMultiset;

// Auxiliary functions definition
//
inline void DoNothing() { }
template<typename T>
inline T Abs(const T a) { return a < 0 ? -a : a; }
template<typename T>
inline T Min(const T a, const T b) {return a < b ? a : b;}
template<typename T>
inline T Max(const T a, const T b) {return a > b ? a : b;}

static const double eps = 1.0e-8;
inline double IsEqual(const double a, const double b) { return Abs(a - b) < eps; }
inline double IsGreater(const double a, const double b) { return a > b + eps; }
inline double IsLess(const double a, const double b) { return a + eps < b; }

struct Rand
{
    uint32 z_, w_;
    uint32 get32() { z_ = 36969 * (z_ & 65535) + (z_ >> 16); w_ = 18000 * (w_ & 65535) + (w_ >> 16); return (z_ << 16) + (w_ & 65535); }
    void Reset() { z_ = 1; w_ = 1; }
    Rand() { Reset(); }
};

#ifndef ONLINE_JUDGE
#define PRINT(a) std::cout << '\t' << #a << " = " << (a) << "; "
#define NEWLINE() std::cout << std::endl;
#else //ONLINE_JUDGE
#define PRINT(a) DoNothing()
#define NEWLINE() DoNothing()
#endif //ONLINE_JUDGE

// Local functions definition
//

struct Operation
{
    enum EOpType { OP_INSERT, OP_DELETE, OP_REPLACE, OP_NOTHNING};

    EOpType opType;
    size_t pos;
    char ch;

    Operation(): opType(OP_NOTHNING) { }

    Operation(const EOpType opType_, const size_t pos_, const char ch_): opType(opType_), pos(pos_), ch(ch_) { }

    static Operation CreateInsert(const size_t pos, const char ch)
    {
        return Operation(OP_INSERT, pos, ch);
    }

    static Operation CreateDelete(const size_t pos)
    {
        return Operation(OP_DELETE, pos, ' ');
    }

    static Operation CreateReplace(const size_t pos, const char ch)
    {
        return Operation(OP_REPLACE, pos, ch);
    }

    static Operation CreateNothing()
    {
        return Operation(OP_NOTHNING, 0, ' ');
    }

    std::ostream& put(std::ostream& os) const
    {
        switch (opType)
        {
        case OP_INSERT:
            os << "INSERT " << pos + 1 << ' ' << ch;
            break;
        case OP_DELETE:
            os << "DELETE " << pos + 1;
            break;
        case OP_REPLACE:
            os << "REPLACE " << pos + 1 << ' ' << ch;
            break;
        }
        return os;
    }

    void Apply(std::string& str) const
    {
        switch (opType)
        {
        case OP_INSERT:
            str.insert(pos, 1, ch);
            break;
        case OP_DELETE:
            str.erase(pos, 1);
            break;
        case OP_REPLACE:
            str[pos] = ch;
            break;
        }
    }

    bool operator==(const Operation& rval) const
    {
        if (this->opType != rval.opType) {return false;}
        else
        {
            switch (opType)
            {
            case OP_INSERT:
                return this->pos == rval.pos && this->ch == rval.ch;
                break;
            case OP_DELETE:
                return this->pos == rval.pos;
                break;
            case OP_REPLACE:
                return this->pos == rval.pos && this->ch == rval.ch;
                break;
            default:
                return true;
            }
        }
    }
};

std::ostream& operator<<(std::ostream& os, const Operation& op)
{
    return op.put(os);
}

typedef std::vector<Operation> OperationVector;
typedef std::vector<Operation::EOpType> OpTypeVector;

struct DataField
{
    bool bFullyCalculated;
    bool bValid; // at least one time was assigned
    size_t bestOpCount; // valid only if bValid=true, minimum operation count
    Operation::EOpType bestOperation; // valid only if bValid=true, best operation description

    DataField(): bFullyCalculated(false), bValid(false), bestOpCount(0) {}

    void TryToSetOperation(const Operation::EOpType& operation, const size_t opCount)
    {
        if (!bValid || opCount < bestOpCount)
        {
            bValid = true;
            bestOpCount = opCount;
            bestOperation = operation;
        }
    }
};

typedef std::vector<std::vector<DataField> > DataFieldVector2d;

template <typename T> std::vector<std::vector<T> > CreateVector2d(const size_t rowCnt, const size_t colCnt)
{
    return std::vector<std::vector<T> > (rowCnt, std::vector<T>(colCnt));
}

OperationVector FindAnswerNoRec(const std::string& strSrc, const std::string strDst)
{
    StopWatch sw("Non-recursive calculation");

    const size_t sizeSrc = strSrc.size();
    const size_t sizeDst = strDst.size();
    DataFieldVector2d data = CreateVector2d<DataField>(sizeSrc+1, sizeDst+1);

    data[0][0].bValid = true;
    data[0][0].bestOpCount = 0;

    for (size_t subSrcLen = 0; subSrcLen <= sizeSrc; ++subSrcLen)
    {
        for (size_t subDstLen = 0; subDstLen <= sizeDst; ++subDstLen)
        {
            if (subDstLen > 0 && subSrcLen > 0)
            {
                // Try to replace
                const size_t prevOpCnt = data[subSrcLen-1][subDstLen-1].bestOpCount;
                const bool bReplaceIsNeeded = (strSrc[subSrcLen-1] != strDst[subDstLen-1]);
                if (bReplaceIsNeeded)
                {
                    data[subSrcLen][subDstLen].TryToSetOperation(Operation::OP_REPLACE, prevOpCnt + 1);
                }
                else
                {
                    data[subSrcLen][subDstLen].TryToSetOperation(Operation::OP_NOTHNING, prevOpCnt);
                }
            }

            if (subSrcLen > 0)
            {
                // Try to delete
                const size_t prevOpCnt = data[subSrcLen-1][subDstLen].bestOpCount;
                data[subSrcLen][subDstLen].TryToSetOperation(Operation::OP_DELETE, prevOpCnt + 1);
            }

            if (subDstLen > 0)
            {
                // Try to append
                const size_t prevOpCnt = data[subSrcLen][subDstLen-1].bestOpCount;
                data[subSrcLen][subDstLen].TryToSetOperation(Operation::OP_INSERT, prevOpCnt + 1);
            }
        }
    }

#ifndef ONLINE_JUDGE
    std::cout << "Opcount = " << data[sizeSrc][sizeDst].bestOpCount << std::endl;
#endif //ONLINE_JUDGE

    // find operation sequence
    OperationVector ans;

    size_t idxSrc = sizeSrc;
    size_t idxDst = sizeDst;
    while (idxSrc != 0 || idxDst != 0)
    {
        switch (data[idxSrc][idxDst].bestOperation)
        {
        case Operation::OP_DELETE:
            ans.push_back(Operation::CreateDelete(idxDst));
            idxSrc--;
            break;
        case Operation::OP_INSERT:
            ans.push_back(Operation::CreateInsert(idxDst-1, strDst[idxDst-1]));
            idxDst--;
            break;
        case Operation::OP_REPLACE:
            ans.push_back(Operation::CreateReplace(idxDst-1, strDst[idxDst-1]));
            idxDst--;
            idxSrc--;
            break;
        case Operation::OP_NOTHNING:
            idxDst--;
            idxSrc--;
            break;
        }
    }

    std::reverse(ans.begin(), ans.end());

    return ans;
}

void FillDataTableRec(const std::string& strSrc, const std::string& strDst, DataFieldVector2d& data, size_t subSrcLen, size_t subDstLen)
{
    DataField& curDataField = data[subSrcLen][subDstLen];

    if (subSrcLen == 0 && subDstLen == 0)
    {
        curDataField.bValid = true;
        curDataField.bestOpCount = 0;
        curDataField.bestOperation =  Operation::OP_NOTHNING;
    }

    if (subSrcLen > 0 && subDstLen > 0)
    {
        DataField& prevDataField = data[subSrcLen-1][subDstLen-1];

        if (!prevDataField.bFullyCalculated)
        {
            FillDataTableRec(strSrc, strDst, data, subSrcLen-1, subDstLen-1);
        }

        if (strSrc[subSrcLen-1] != strDst[subDstLen-1])
        {
            curDataField.TryToSetOperation(Operation::OP_REPLACE, prevDataField.bestOpCount + 1);
        }
        else
        {
            curDataField.TryToSetOperation(Operation::OP_NOTHNING, prevDataField.bestOpCount);
        }
    }

    if (subDstLen > 0)
    {
        DataField& prevDataField = data[subSrcLen][subDstLen-1];

        if (!prevDataField.bFullyCalculated)
        {
            FillDataTableRec(strSrc, strDst, data, subSrcLen, subDstLen-1);
        }

        curDataField.TryToSetOperation(Operation::OP_INSERT, prevDataField.bestOpCount + 1);
    }

    if (subSrcLen > 0)
    {
        DataField& prevDataField = data[subSrcLen-1][subDstLen];

        if (!prevDataField.bFullyCalculated)
        {
            FillDataTableRec(strSrc, strDst, data, subSrcLen-1, subDstLen);
        }

        curDataField.TryToSetOperation(Operation::OP_DELETE, prevDataField.bestOpCount + 1);
    }

    curDataField.bFullyCalculated = true;
}

OperationVector FindAnswerRec(const std::string& strSrc, const std::string strDst)
{
    StopWatch sw("Recursive calculation");

    const size_t sizeSrc = strSrc.size();
    const size_t sizeDst = strDst.size();

    DataFieldVector2d data = CreateVector2d<DataField>(strSrc.size() + 1, strDst.size() + 1);
    FillDataTableRec(strSrc, strDst, data, sizeSrc, sizeDst);

#ifndef ONLINE_JUDGE
    std::cout << "Opcount = " << data[sizeSrc][sizeDst].bestOpCount << std::endl;
#endif //ONLINE_JUDGE

    // find operation sequence
    OperationVector ans;

    size_t idxSrc = sizeSrc;
    size_t idxDst = sizeDst;
    while (idxSrc != 0 || idxDst != 0)
    {
        switch (data[idxSrc][idxDst].bestOperation)
        {
        case Operation::OP_DELETE:
            ans.push_back(Operation::CreateDelete(idxDst));
            idxSrc--;
            break;
        case Operation::OP_INSERT:
            ans.push_back(Operation::CreateInsert(idxDst-1, strDst[idxDst-1]));
            idxDst--;
            break;
        case Operation::OP_REPLACE:
            ans.push_back(Operation::CreateReplace(idxDst-1, strDst[idxDst-1]));
            idxDst--;
            idxSrc--;
            break;
        case Operation::OP_NOTHNING:
            idxDst--;
            idxSrc--;
            break;
        }
    }

    std::reverse(ans.begin(), ans.end());

    return ans;
}

bool CheckAnswer(const std::string& strSrc, const std::string& strDst, const OperationVector& ans)
{
    std::string strRes(strSrc);
    for (size_t i = 0; i < ans.size(); ++i)
    {
        ans[i].Apply(strRes);
    }

    std::cout << "strSrc = " << strSrc << std::endl;
    std::cout << "strDst = " << strDst << std::endl;
    std::cout << "strRes = " << strRes << std::endl;

    const bool bEq = strDst == strRes;
    std::cout << (bEq ? "OK" : "NOT ok") << std::endl;

    return bEq;
}

bool Solve(bool bCheckInputStream = false)
{
    // First input operation
    //
    std::string strSrc, strDst;
    std::cin >> strSrc >> strDst;
    // End of first input operation

    if (bCheckInputStream && !std::cin)
    {
        return false;
    }

    StopWatch _sw;

    // Other input operations and calculations
    //

    //const OperationVector ansNoRec = FindAnswerNoRec(strSrc, strDst);
    const OperationVector ansRec = FindAnswerRec(strSrc, strDst);

    const OperationVector& ans = ansRec;

    std::cout << ans.size() << std::endl;
    for (size_t i = 0; i < ans.size(); ++i)
    {
        std::cout << ans[i] << std::endl;
    }

    // check sequence
#ifndef ONLINE_JUDGE
    CheckAnswer(strSrc, strDst, ans);
#endif //ONLINE_JUDGE

    return true;
    // End of all calculations
}

int main()
{
#if defined(ONLINE_JUDGE)
    Solve();
#else //defined(ONLINE_JUDGE)
    //while (Solve(true))   { std::cout << std::endl; }
    Solve();
#endif //defined(ONLINE_JUDGE)
}


#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

#if !defined(ONLINE_JUDGE)
#include <windows.h>
class StopWatch
{
	DWORD tickStart;
	std::string name;
public:
	StopWatch(const char *str = NULL): tickStart(GetTickCount()), name(str ? str : "Time") {}
	~StopWatch() {std::cout << name << ": " << (GetTickCount() - tickStart) << " ms" << std::endl;}
};
#else //!defined(ONLINE_JUDGE)
class StopWatch {public: StopWatch(const char *) {} StopWatch() {}};
#endif //!defined(ONLINE_JUDGE)

// Types definition
//
typedef signed char					int8;
typedef unsigned char				uint8;
typedef signed short                int16;
typedef unsigned short              uint16;
typedef signed long					int32;
typedef unsigned long				uint32;
typedef signed long long			int64;
typedef unsigned long long			uint64;

typedef std::vector<size_t>			SizeTVector;
typedef std::set<size_t>			SizeTSet;
typedef std::multiset<size_t>		SizeTMultiset;

typedef std::vector<std::string>	StringVector;
typedef std::set<std::string>		StringSet;
typedef std::multiset<std::string>	StringMultiset;

// Auxiliary functions definition
//
inline void DoNothing() { }
template<typename T>
inline T Abs(const T a) { return a < 0 ? -a : a; }
template<typename T>
inline T Min(const T a, const T b) {return a < b ? a : b;}
template<typename T>
inline T Max(const T a, const T b) {return a > b ? a : b;}

static const double eps = 1.0e-8;
inline double IsEqual(const double a, const double b) { return Abs(a - b) < eps; }
inline double IsGreater(const double a, const double b) { return a > b + eps; }
inline double IsLess(const double a, const double b) { return a + eps < b; }

struct Rand
{
	uint32 z_, w_;
	uint32 get32() { z_ = 36969 * (z_ & 65535) + (z_ >> 16); w_ = 18000 * (w_ & 65535) + (w_ >> 16); return (z_ << 16) + (w_ & 65535); }
	void Reset() { z_ = 1; w_ = 1; }
	Rand() { Reset(); }
};

#ifndef ONLINE_JUDGE
#define PRINT(a) std::cout << '\t' << #a << " = " << (a) << "; "
#define NEWLINE() std::cout << std::endl;
#else //ONLINE_JUDGE
#define PRINT(a) DoNothing()
#define NEWLINE() DoNothing()
#endif //ONLINE_JUDGE

// Local functions definition
//

struct Operation
{
	enum EOpType { OP_INSERT, OP_DELETE, OP_REPLACE, OP_NOTHNING};

	EOpType opType;
	size_t pos;
	char ch;

	Operation(): opType(OP_NOTHNING) { }

	Operation(const EOpType opType_, const size_t pos_, const char ch_): opType(opType_), pos(pos_), ch(ch_) { }

	static Operation CreateInsert(const size_t pos, const char ch)
	{
		return Operation(OP_INSERT, pos, ch);
	}

	static Operation CreateDelete(const size_t pos)
	{
		return Operation(OP_DELETE, pos, ' ');
	}

	static Operation CreateReplace(const size_t pos, const char ch)
	{
		return Operation(OP_REPLACE, pos, ch);
	}

	static Operation CreateNothing()
	{
		return Operation(OP_NOTHNING, 0, ' ');
	}

	std::ostream& operator<<(std::ostream& os) const
	{
		switch (opType)
		{
		case OP_INSERT:
			os << "INSERT " << pos + 1 << ' ' << ch;
			break;
		case OP_DELETE:
			os << "DELETE " << pos + 1;
			break;
		case OP_REPLACE:
			os << "REPLACE " << pos + 1 << ' ' << ch;
			break;
		}
		return os;
	}

	void Apply(std::string& str) const
	{
		switch (opType)
		{
		case OP_INSERT:
			str.insert(pos, 1, ch);
			break;
		case OP_DELETE:
			str.erase(pos, 1);
			break;
		case OP_REPLACE:
			str[pos] = ch;
			break;
		}
	}
};

std::ostream& operator<<(std::ostream& os, const Operation& op)
{
	return op.operator<<(os);
}

typedef std::vector<Operation> OperationVector;

struct DataField
{
	bool bFullyCalculated;
	bool bValid; // at least one time was assigned
	size_t bestOpCount; // valid only if bValid=true, minimum operation count
	Operation bestOperation; // valid only if bValid=true, best operation description

	DataField(): bFullyCalculated(false), bValid(false), bestOpCount(0) {}

	void TryToSetOperation(const Operation& operation, const size_t opCount)
	{
		if (!bValid || opCount < bestOpCount)
		{
			bValid = true;
			bestOpCount = opCount;
			bestOperation = operation;
		}
	}
};

typedef std::vector<std::vector<DataField> > DataFieldVector2d;

template <typename T>
std::vector<std::vector<T> > CreateVector2d(const size_t rowCnt, const size_t colCnt)
{
	std::vector<std::vector<T> > result;
	for (size_t row = 0; row < rowCnt; ++row)
	{
		result.push_back(std::vector<T>(colCnt));
	}
	return result;
}

bool Solve(bool bCheckInputStream = false)
{
	// First input operation
	//
	std::string strSrc, strDst;
	std::cin >> strSrc >> strDst;
	// End of first input operation

	if (bCheckInputStream && !std::cin)
	{
		return false;
	}

	StopWatch _sw;

	// Other input operations and calculations
	//
	const size_t sizeSrc = strSrc.size();
	const size_t sizeDst = strDst.size();
	DataFieldVector2d data = CreateVector2d<DataField>(sizeSrc+1, sizeDst+1);

	data[0][0].bValid = true;
	data[0][0].bestOpCount = 0;

	for (size_t subSrcLen = 0; subSrcLen <= sizeSrc; ++subSrcLen)
	{
		for (size_t subDstLen = 0; subDstLen <= sizeDst; ++subDstLen)
		{
			if (subDstLen > 0 && subSrcLen > 0)
			{
				// Try to replace
				const size_t prevOpCnt = data[subSrcLen-1][subDstLen-1].bestOpCount;
				const bool bReplaceIsNeeded = (strSrc[subSrcLen-1] != strDst[subDstLen-1]);
				if (bReplaceIsNeeded)
				{
					data[subSrcLen][subDstLen].TryToSetOperation(Operation::CreateReplace(subDstLen-1, strDst[subDstLen-1]), prevOpCnt + 1);
				}
				else
				{
					data[subSrcLen][subDstLen].TryToSetOperation(Operation::CreateNothing(), prevOpCnt);
				}
			}

			if (subSrcLen > 0)
			{
				// Try to delete
				const size_t prevOpCnt = data[subSrcLen-1][subDstLen].bestOpCount;
				data[subSrcLen][subDstLen].TryToSetOperation(Operation::CreateDelete(subDstLen), prevOpCnt + 1);
			}

			if (subDstLen > 0)
			{
				// Try to append
				const size_t prevOpCnt = data[subSrcLen][subDstLen-1].bestOpCount;
				data[subSrcLen][subDstLen].TryToSetOperation(Operation::CreateInsert(subDstLen-1, strDst[subDstLen-1]), prevOpCnt + 1);
			}
		}
	}

#ifndef ONLINE_JUDGE
	std::cout << "Opcount = " << data[sizeSrc][sizeDst].bestOpCount << std::endl;
#endif //ONLINE_JUDGE

	// find operation sequence
	OperationVector ans;

	size_t idxSrc = sizeSrc;
	size_t idxDst = sizeDst;
	while (idxSrc != 0 || idxDst != 0)
	{
		const DataField& dataField = data[idxSrc][idxDst];
		switch (dataField.bestOperation.opType)
		{
		case Operation::OP_DELETE:
			ans.push_back(dataField.bestOperation);
			idxSrc--;
			break;
		case Operation::OP_INSERT:
			ans.push_back(dataField.bestOperation);
			idxDst--;
			break;
		case Operation::OP_REPLACE:
			ans.push_back(dataField.bestOperation);
			idxDst--;
			idxSrc--;
			break;
		case Operation::OP_NOTHNING:
			idxDst--;
			idxSrc--;
			break;
		}
	}

	std::reverse(ans.begin(), ans.end());

	std::cout << ans.size() << std::endl;
	for (size_t i = 0; i < ans.size(); ++i)
	{
		std::cout << ans[i];
		std::cout << std::endl;
	}

	// check sequence
#ifndef ONLINE_JUDGE
	std::string strRes(strSrc);
	for (size_t i = 0; i < ans.size(); ++i)
	{
		ans[i].Apply(strRes);
	}
	std::cout << "strSrc = " << strSrc << std::endl;
	std::cout << "strDst = " << strDst << std::endl;
	std::cout << "strRes = " << strRes << std::endl;
#endif //ONLINE_JUDGE

	return true;
	// End of all calculations
}

int main()
{
#if defined(ONLINE_JUDGE)
	Solve();
#else //defined(ONLINE_JUDGE)
	while (Solve(true))	{ }
	//Solve();
#endif //defined(ONLINE_JUDGE)
}


#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

#if !defined(ONLINE_JUDGE)
#include <windows.h>
class StopWatch
{
    DWORD tickStart;
    std::string name;
public:
    StopWatch(const char *str = NULL): tickStart(GetTickCount()), name(str ? str : "Time") {}
    ~StopWatch() {std::cout << name << ": " << (GetTickCount() - tickStart) << " ms" << std::endl;}
};
#else //!defined(ONLINE_JUDGE)
class StopWatch {public: StopWatch(const char *) {} StopWatch() {}};
#endif //!defined(ONLINE_JUDGE)

// Types definition
//
typedef signed char                 int8;
typedef unsigned char               uint8;
typedef signed short                int16;
typedef unsigned short              uint16;
typedef signed long                 int32;
typedef unsigned long               uint32;
typedef signed long long            int64;
typedef unsigned long long          uint64;

typedef std::vector<size_t>         SizeTVector;
typedef std::set<size_t>            SizeTSet;
typedef std::multiset<size_t>       SizeTMultiset;

typedef std::vector<std::string>    StringVector;
typedef std::set<std::string>       StringSet;
typedef std::multiset<std::string>  StringMultiset;

// Auxiliary functions definition
//
inline void DoNothing() { }
template<typename T>
inline T Abs(const T a) { return a < 0 ? -a : a; }
template<typename T>
inline T Min(const T a, const T b) {return a < b ? a : b;}
template<typename T>
inline T Max(const T a, const T b) {return a > b ? a : b;}

static const double eps = 1.0e-8;
inline double IsEqual(const double a, const double b) { return Abs(a - b) < eps; }
inline double IsGreater(const double a, const double b) { return a > b + eps; }
inline double IsLess(const double a, const double b) { return a + eps < b; }

struct Rand
{
    uint32 z_, w_;
    uint32 get32() { z_ = 36969 * (z_ & 65535) + (z_ >> 16); w_ = 18000 * (w_ & 65535) + (w_ >> 16); return (z_ << 16) + (w_ & 65535); }
    void Reset() { z_ = 1; w_ = 1; }
    Rand() { Reset(); }
};

#ifndef ONLINE_JUDGE
#define PRINT(a) std::cout << '\t' << #a << " = " << (a) << "; "
#define NEWLINE() std::cout << std::endl;
#else //ONLINE_JUDGE
#define PRINT(a) DoNothing()
#define NEWLINE() DoNothing()
#endif //ONLINE_JUDGE

// Local functions definition
//

struct Operation
{
    enum EOpType { OP_INSERT, OP_DELETE, OP_REPLACE, OP_NOTHNING};

    EOpType opType;
    size_t pos;
    char ch;

    Operation(): opType(OP_NOTHNING) { }

    Operation(const EOpType opType_, const size_t pos_, const char ch_): opType(opType_), pos(pos_), ch(ch_) { }

    static Operation CreateInsert(const size_t pos, const char ch)
    {
        return Operation(OP_INSERT, pos, ch);
    }

    static Operation CreateDelete(const size_t pos)
    {
        return Operation(OP_DELETE, pos, ' ');
    }

    static Operation CreateReplace(const size_t pos, const char ch)
    {
        return Operation(OP_REPLACE, pos, ch);
    }

    static Operation CreateNothing()
    {
        return Operation(OP_NOTHNING, 0, ' ');
    }

    std::ostream& put(std::ostream& os) const
    {
        switch (opType)
        {
        case OP_INSERT:
            os << "INSERT " << pos + 1 << ' ' << ch;
            break;
        case OP_DELETE:
            os << "DELETE " << pos + 1;
            break;
        case OP_REPLACE:
            os << "REPLACE " << pos + 1 << ' ' << ch;
            break;
        }
        return os;
    }

    void Apply(std::string& str) const
    {
        switch (opType)
        {
        case OP_INSERT:
            str.insert(pos, 1, ch);
            break;
        case OP_DELETE:
            str.erase(pos, 1);
            break;
        case OP_REPLACE:
            str[pos] = ch;
            break;
        }
    }
};

std::ostream& operator<<(std::ostream& os, const Operation& op)
{
    return op.put(os);
}

typedef std::vector<Operation> OperationVector;
typedef std::vector<Operation::EOpType> OpTypeVector;

struct DataField
{
    bool bFullyCalculated;
    bool bValid; // at least one time was assigned
    size_t bestOpCount; // valid only if bValid=true, minimum operation count
    Operation bestOperation; // valid only if bValid=true, best operation description

    DataField(): bFullyCalculated(false), bValid(false), bestOpCount(0) {}

    void TryToSetOperation(const Operation& operation, const size_t opCount)
    {
        if (!bValid || opCount < bestOpCount)
        {
            bValid = true;
            bestOpCount = opCount;
            bestOperation = operation;
        }
    }
};

struct DataField2
{
    bool bFullyCalculated;
    bool bValid; // at least one time was assigned
    size_t bestOpCount; // valid only if bValid=true, minimum operation count
    Operation::EOpType bestOperation; // valid only if bValid=true, best operation description

    DataField2(): bFullyCalculated(false), bValid(false), bestOpCount(0) {}

    void TryToSetOperation(const Operation::EOpType& operation, const size_t opCount)
    {
        if (!bValid || opCount < bestOpCount)
        {
            bValid = true;
            bestOpCount = opCount;
            bestOperation = operation;
        }
    }
};

typedef std::vector<std::vector<DataField> > DataFieldVector2d;
typedef std::vector<std::vector<DataField2> > DataField2Vector2d;

template <typename T>
std::vector<std::vector<T> > CreateVector2d(const size_t rowCnt, const size_t colCnt)
{
    std::vector<std::vector<T> > result;
    for (size_t row = 0; row < rowCnt; ++row)
    {
        result.push_back(std::vector<T>(colCnt));
    }
    return result;
}

OperationVector FindAnswerNoRec1(const std::string& strSrc, const std::string strDst)
{
    const size_t sizeSrc = strSrc.size();
    const size_t sizeDst = strDst.size();
    DataFieldVector2d data = CreateVector2d<DataField>(sizeSrc+1, sizeDst+1);

    data[0][0].bValid = true;
    data[0][0].bestOpCount = 0;

    for (size_t subSrcLen = 0; subSrcLen <= sizeSrc; ++subSrcLen)
    {
        for (size_t subDstLen = 0; subDstLen <= sizeDst; ++subDstLen)
        {
            if (subDstLen > 0 && subSrcLen > 0)
            {
                // Try to replace
                const size_t prevOpCnt = data[subSrcLen-1][subDstLen-1].bestOpCount;
                const bool bReplaceIsNeeded = (strSrc[subSrcLen-1] != strDst[subDstLen-1]);
                if (bReplaceIsNeeded)
                {
                    data[subSrcLen][subDstLen].TryToSetOperation(Operation::CreateReplace(subDstLen-1, strDst[subDstLen-1]), prevOpCnt + 1);
                }
                else
                {
                    data[subSrcLen][subDstLen].TryToSetOperation(Operation::CreateNothing(), prevOpCnt);
                }
            }

            if (subSrcLen > 0)
            {
                // Try to delete
                const size_t prevOpCnt = data[subSrcLen-1][subDstLen].bestOpCount;
                data[subSrcLen][subDstLen].TryToSetOperation(Operation::CreateDelete(subDstLen), prevOpCnt + 1);
            }

            if (subDstLen > 0)
            {
                // Try to append
                const size_t prevOpCnt = data[subSrcLen][subDstLen-1].bestOpCount;
                data[subSrcLen][subDstLen].TryToSetOperation(Operation::CreateInsert(subDstLen-1, strDst[subDstLen-1]), prevOpCnt + 1);
            }
        }
    }

#ifndef ONLINE_JUDGE
    std::cout << "Opcount = " << data[sizeSrc][sizeDst].bestOpCount << std::endl;
#endif //ONLINE_JUDGE

    // find operation sequence
    OperationVector ans;

    size_t idxSrc = sizeSrc;
    size_t idxDst = sizeDst;
    while (idxSrc != 0 || idxDst != 0)
    {
        const DataField& dataField = data[idxSrc][idxDst];
        switch (dataField.bestOperation.opType)
        {
        case Operation::OP_DELETE:
            ans.push_back(dataField.bestOperation);
            idxSrc--;
            break;
        case Operation::OP_INSERT:
            ans.push_back(dataField.bestOperation);
            idxDst--;
            break;
        case Operation::OP_REPLACE:
            ans.push_back(dataField.bestOperation);
            idxDst--;
            idxSrc--;
            break;
        case Operation::OP_NOTHNING:
            idxDst--;
            idxSrc--;
            break;
        }
    }

    std::reverse(ans.begin(), ans.end());

    return ans;
}

OperationVector FindAnswerNoRec2(const std::string& strSrc, const std::string strDst)
{
    const size_t sizeSrc = strSrc.size();
    const size_t sizeDst = strDst.size();
    DataField2Vector2d data = CreateVector2d<DataField2>(sizeSrc+1, sizeDst+1);

    data[0][0].bValid = true;
    data[0][0].bestOpCount = 0;

    for (size_t subSrcLen = 0; subSrcLen <= sizeSrc; ++subSrcLen)
    {
        for (size_t subDstLen = 0; subDstLen <= sizeDst; ++subDstLen)
        {
            if (subDstLen > 0 && subSrcLen > 0)
            {
                // Try to replace
                const size_t prevOpCnt = data[subSrcLen-1][subDstLen-1].bestOpCount;
                const bool bReplaceIsNeeded = (strSrc[subSrcLen-1] != strDst[subDstLen-1]);
                if (bReplaceIsNeeded)
                {
                    data[subSrcLen][subDstLen].TryToSetOperation(Operation::OP_REPLACE, prevOpCnt + 1);
                }
                else
                {
                    data[subSrcLen][subDstLen].TryToSetOperation(Operation::OP_NOTHNING, prevOpCnt);
                }
            }

            if (subSrcLen > 0)
            {
                // Try to delete
                const size_t prevOpCnt = data[subSrcLen-1][subDstLen].bestOpCount;
                data[subSrcLen][subDstLen].TryToSetOperation(Operation::OP_DELETE, prevOpCnt + 1);
            }

            if (subDstLen > 0)
            {
                // Try to append
                const size_t prevOpCnt = data[subSrcLen][subDstLen-1].bestOpCount;
                data[subSrcLen][subDstLen].TryToSetOperation(Operation::OP_INSERT, prevOpCnt + 1);
            }
        }
    }

#ifndef ONLINE_JUDGE
    std::cout << "Opcount = " << data[sizeSrc][sizeDst].bestOpCount << std::endl;
#endif //ONLINE_JUDGE

    // find operation sequence
    OperationVector ans;

    size_t idxSrc = sizeSrc;
    size_t idxDst = sizeDst;
    while (idxSrc != 0 || idxDst != 0)
    {
        const DataField2& dataField = data[idxSrc][idxDst];
        switch (dataField.bestOperation)
        {
        case Operation::OP_DELETE:
            ans.push_back(Operation::CreateDelete(idxDst));
            idxSrc--;
            break;
        case Operation::OP_INSERT:
            ans.push_back(Operation::CreateInsert(idxDst-1, strDst[idxDst-1]));
            idxDst--;
            break;
        case Operation::OP_REPLACE:
            ans.push_back(Operation::CreateReplace(idxDst-1, strDst[idxDst-1]));
            idxDst--;
            idxSrc--;
            break;
        case Operation::OP_NOTHNING:
            idxDst--;
            idxSrc--;
            break;
        }
    }

    std::reverse(ans.begin(), ans.end());

    return ans;
}

bool CheckAnswer(const std::string& strSrc, const std::string& strDst, const OperationVector& ans)
{
    std::string strRes(strSrc);
    for (size_t i = 0; i < ans.size(); ++i)
    {
        ans[i].Apply(strRes);
    }

    std::cout << "strSrc = " << strSrc << std::endl;
    std::cout << "strDst = " << strDst << std::endl;
    std::cout << "strRes = " << strRes << std::endl;

    const bool bEq = strDst == strRes;
    std::cout << (bEq ? "OK" : "NOT ok") << std::endl;

    return bEq;
}

bool Solve(bool bCheckInputStream = false)
{
    // First input operation
    //
    std::string strSrc, strDst;
    std::cin >> strSrc >> strDst;
    // End of first input operation

    if (bCheckInputStream && !std::cin)
    {
        return false;
    }

    StopWatch _sw;

    // Other input operations and calculations
    //

    const OperationVector ans = FindAnswerNoRec2(strSrc, strDst);

    std::cout << ans.size() << std::endl;
    for (size_t i = 0; i < ans.size(); ++i)
    {
        std::cout << ans[i] << std::endl;
    }

    // check sequence
#ifndef ONLINE_JUDGE
    CheckAnswer(strSrc, strDst, ans);
#endif //ONLINE_JUDGE

    return true;
    // End of all calculations
}

int main()
{
#if defined(ONLINE_JUDGE)
    Solve();
#else //defined(ONLINE_JUDGE)
    while (Solve(true)) { std::cout << std::endl; }
    //Solve();
#endif //defined(ONLINE_JUDGE)
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <complex>
using namespace std;
#define pb push_back

const int maxn=1005, inf=100000000;
int dp[maxn][maxn], prv[maxn][maxn];
char s1[maxn], s2[maxn];
vector<pair<string, pair<int, char> > > vc;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n1, n2, i, j, tmp;
    scanf("%s %s", &s1[1], &s2[1]);
    s1[0]=s2[0]='#';
    n1=strlen(s1)-1;
    n2=strlen(s2)-1;
    for(i=0; i<=n1; i++)
        for(j=0; j<=n2; j++)
            dp[i][j]=inf;
    dp[0][0]=0;
    for(i=1; i<=n1; i++)
    {
        dp[i][0]=i;
        prv[i][0]=2;
    }
    for(j=1; i<=n2; i++)
    {
        dp[0][j]=i;
        prv[0][j]=1;
    }
    for(i=1; i<=n1; i++)
        for(j=1; j<=n2; j++)
        {
            if (s1[i]==s2[j])
            {
                if (dp[i-1][j-1]<dp[i][j])
                {
                    dp[i][j]=dp[i-1][j-1];
                    prv[i][j]=3;
                }
            }
            else
            {
                if (dp[i-1][j-1]+1<dp[i][j])
                {
                    dp[i][j]=dp[i-1][j-1]+1;
                    prv[i][j]=3;
                }
            }
            if (dp[i][j-1]+1<dp[i][j])
            {
                dp[i][j]=dp[i][j-1]+1;
                prv[i][j]=1;
            }
            if (dp[i-1][j]+1<dp[i][j])
            {
                dp[i][j]=dp[i-1][j]+1;
                prv[i][j]=2;
            }
        }
    printf("%d\n", dp[n1][n2]);
    for(i=n1, j=n2; i || j; )
    {
        tmp=prv[i][j];
        if (tmp==3 && dp[i-1][j-1]!=dp[i][j])
            vc.pb(make_pair("REPLACE", make_pair(j, s2[j])));
        if (tmp==2)
            vc.pb(make_pair("DELETE", make_pair(j+1, 0)));
        if (tmp==1)
            vc.pb(make_pair("INSERT", make_pair(j, s2[j])));
        i-=((tmp&2)>>1);
        j-=(tmp&1);
    }
    for(i=(int)vc.size()-1; i>=0; i--)
    {
        cout << vc[i].first << " " << vc[i].second.first;
        if (vc[i].second.second)
            cout << " " << vc[i].second.second;
        putchar('\n');
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <complex>
using namespace std;
#define pb push_back

const int maxn=1005, inf=100000000;
int dp[maxn][maxn], prv[maxn][maxn];
char s1[maxn], s2[maxn];
vector<pair<string, pair<int, char> > > vc;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n1, n2, i, j, tmp;
    scanf("%s %s", &s1[1], &s2[1]);
    s1[0]=s2[0]='#';
    n1=strlen(s1)-1;
    n2=strlen(s2)-1;
    for(i=0; i<=n1; i++)
        for(j=0; j<=n2; j++)
            dp[i][j]=inf;
    dp[0][0]=0;
    /*for(i=1; i<=n1; i++)
    {
        dp[i][0]=i;
        prv[i][0]=2;
    }
    for(j=1; i<=n2; i++)
    {
        dp[0][j]=i;
        prv[0][j]=1;
    }*/
    for(i=0; i<n1; i++)
        for(j=0; j<n2; j++)
        {
            if (i<n1 && j<n2)
            {
                if (s1[i+1]==s2[j+1])
                {
                    if (dp[i][j]<dp[i+1][j+1])
                    {
                        dp[i+1][j+1]=dp[i][j];
                        prv[i+1][j+1]=3;
                    }
                }
                else
                {
                    if (dp[i][j]+1<dp[i+1][j+1])
                    {
                        dp[i+1][j+1]=dp[i][j]+1;
                        prv[i+1][j+1]=3;
                    }
                }
            }
            if (j<n2)
            {
                if (dp[i][j]+1<dp[i][j+1])
                {
                    dp[i][j+1]=dp[i][j]+1;
                    prv[i][j+1]=1;
                }
            }
            if (i<n1)
            {
                if (dp[i][j]+1<dp[i+1][j])
                {
                    dp[i+1][j]=dp[i][j]+1;
                    prv[i+1][j]=2;
                }
            }
        }
    printf("%d\n", dp[n1][n2]);
    for(i=n1, j=n2; i || j; )
    {
        tmp=prv[i][j];
        if (tmp==3 && dp[i-1][j-1]!=dp[i][j])
            vc.pb(make_pair("REPLACE", make_pair(j, s2[j])));
        if (tmp==2)
            vc.pb(make_pair("DELETE", make_pair(j+1, 0)));
        if (tmp==1)
            vc.pb(make_pair("INSERT", make_pair(j, s2[j])));
        i-=((tmp&2)>>1);
        j-=(tmp&1);
    }
    for(i=(int)vc.size()-1; i>=0; i--)
    {
        cout << vc[i].first << " " << vc[i].second.first;
        if (vc[i].second.second)
            cout << " " << vc[i].second.second;
        putchar('\n');
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <complex>
using namespace std;
#define pb push_back

const int maxn=1005, inf=100000000;
int dp[maxn][maxn], prv[maxn][maxn];
char s1[maxn], s2[maxn];
vector<pair<string, pair<int, char> > > vc;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n1, n2, i, j, tmp;
    scanf("%s %s", &s1[1], &s2[1]);
    s1[0]=s2[0]='#';
    n1=strlen(s1)-1;
    n2=strlen(s2)-1;
    for(i=0; i<=n1; i++)
        for(j=0; j<=n2; j++)
            dp[i][j]=inf;
    dp[0][0]=0;
    /*for(i=1; i<=n1; i++)
    {
        dp[i][0]=i;
        prv[i][0]=2;
    }
    for(j=1; i<=n2; i++)
    {
        dp[0][j]=i;
        prv[0][j]=1;
    }*/
    for(i=0; i<n1; i++)
        for(j=0; j<n2; j++)
        {
            if (i<n1 && j<n2)
            {
                if (s1[i+1]==s2[j+1])
                {
                    if (dp[i][j]<dp[i+1][j+1])
                    {
                        dp[i+1][j+1]=dp[i][j];
                        prv[i+1][j+1]=3;
                    }
                }
                else
                {
                    if (dp[i][j]+1<dp[i+1][j+1])
                    {
                        dp[i+1][j+1]=dp[i][j]+1;
                        prv[i+1][j+1]=3;
                    }
                }
            }
            if (j<n2)
            {
                if (dp[i][j]+1<dp[i][j+1])
                {
                    dp[i][j+1]=dp[i][j]+1;
                    prv[i][j+1]=1;
                }
            }
            if (i<n1)
            {
                if (dp[i][j]+1<dp[i+1][j])
                {
                    dp[i+1][j]=dp[i][j]+1;
                    prv[i+1][j]=2;
                }
            }
        }
    //printf("%d\n", dp[n1][n2]);
    for(i=n1, j=n2; i || j; )
    {
        tmp=prv[i][j];
        if (tmp==3 && dp[i-1][j-1]!=dp[i][j])
            vc.pb(make_pair("REPLACE", make_pair(j, s2[j])));
        if (tmp==2)
            vc.pb(make_pair("DELETE", make_pair(j+1, 0)));
        if (tmp==1)
            vc.pb(make_pair("INSERT", make_pair(j, s2[j])));
        i-=((tmp&2)>>1);
        j-=(tmp&1);
    }
    printf("%d\n", (int)vc.size());
    for(i=(int)vc.size()-1; i>=0; i--)
    {
        cout << vc[i].first << " " << vc[i].second.first;
        if (vc[i].second.second)
            cout << " " << vc[i].second.second;
        putchar('\n');
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <complex>
using namespace std;
#define pb push_back

const int maxn=1005, inf=100000000;
int dp[maxn][maxn], prv[maxn][maxn];
char s1[maxn], s2[maxn];
vector<pair<string, pair<int, char> > > vc;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n1, n2, i, j, tmp;
    scanf("%s %s", &s1[1], &s2[1]);
    s1[0]=s2[0]='#';
    n1=strlen(s1)-1;
    n2=strlen(s2)-1;
    for(i=0; i<=n1; i++)
        for(j=0; j<=n2; j++)
            dp[i][j]=inf;
    dp[0][0]=0;
    /*for(i=1; i<=n1; i++)
    {
        dp[i][0]=i;
        prv[i][0]=2;
    }
    for(j=1; i<=n2; i++)
    {
        dp[0][j]=i;
        prv[0][j]=1;
    }*/
    for(i=0; i<=n1; i++)
        for(j=0; j<=n2; j++)
        {
            if (i<n1 && j<n2)
            {
                if (s1[i+1]==s2[j+1])
                {
                    if (dp[i][j]<dp[i+1][j+1])
                    {
                        dp[i+1][j+1]=dp[i][j];
                        prv[i+1][j+1]=3;
                    }
                }
                else
                {
                    if (dp[i][j]+1<dp[i+1][j+1])
                    {
                        dp[i+1][j+1]=dp[i][j]+1;
                        prv[i+1][j+1]=3;
                    }
                }
            }
            if (j<n2)
            {
                if (dp[i][j]+1<dp[i][j+1])
                {
                    dp[i][j+1]=dp[i][j]+1;
                    prv[i][j+1]=1;
                }
            }
            if (i<n1)
            {
                if (dp[i][j]+1<dp[i+1][j])
                {
                    dp[i+1][j]=dp[i][j]+1;
                    prv[i+1][j]=2;
                }
            }
        }
    //printf("%d\n", dp[n1][n2]);
    for(i=n1, j=n2; i || j; )
    {
        tmp=prv[i][j];
        if (tmp==3 && dp[i-1][j-1]!=dp[i][j])
            vc.pb(make_pair("REPLACE", make_pair(j, s2[j])));
        if (tmp==2)
            vc.pb(make_pair("DELETE", make_pair(j+1, 0)));
        if (tmp==1)
            vc.pb(make_pair("INSERT", make_pair(j, s2[j])));
        i-=((tmp&2)>>1);
        j-=(tmp&1);
    }
    printf("%d\n", (int)vc.size());
    for(i=(int)vc.size()-1; i>=0; i--)
    {
        cout << vc[i].first << " " << vc[i].second.first;
        if (vc[i].second.second)
            cout << " " << vc[i].second.second;
        putchar('\n');
    }
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define mp make_pair
#define pf push_front
#define pb push_back
#define fs first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int,int> pint;
const int MAXN=2000;

enum{DELETE,REPLACE,INSERT,PASSIVE};
int ReverseMoveType[MAXN][MAXN];
int ReverseMoveParametr1[MAXN][MAXN];
char ReverseMoveParametr2[MAXN][MAXN];

int DynamicProgramming[MAXN][MAXN];

string A,B;

void AnswerOutput(int i, int j){
    if (i==0 && j==0)
        return;
    if (ReverseMoveType[i][j]==PASSIVE){
        AnswerOutput(i-1,j-1);
        return;
    }
    if (ReverseMoveType[i][j]==INSERT){
        AnswerOutput(i,j-1);
        cout<<"INSERT "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==DELETE){
        AnswerOutput(i-1,j);
        cout<<"DELETE "<<ReverseMoveParametr1[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==REPLACE){
        AnswerOutput(i-1,j-1);
        cout<<"REPLACE "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>A>>B; int N=A.size(); int M=B.size();

    //Dynamic Programming Base
    for (int i=1;i<=N;i++){
        DynamicProgramming[i][0]=i;
        ReverseMoveType[i][0]=DELETE;
        ReverseMoveParametr1[i][0]=1;
    }
    for (int i=1;i<=M;i++){
        DynamicProgramming[0][i]=i;
        ReverseMoveType[0][i]=INSERT;
        ReverseMoveParametr1[0][i]=i;
        ReverseMoveParametr2[0][i]=B[i-1];
    }
    ReverseMoveType[0][0]=PASSIVE;
    for (int i=1;i<=N;i++)
        for (int j=1;j<=M;j++){
            char CurCharA=A[i-1],CurCharB=B[j-1];

            int InsertVariant=DynamicProgramming[i][j-1]+1
                ,DeleteVariant=DynamicProgramming[i-1][j]+1
                ,ReplaceVariant=DynamicProgramming[i-1][j-1]+1,
                 PassiveVariant=DynamicProgramming[i-1][j-1];
            if (CurCharA==CurCharB && PassiveVariant<=InsertVariant && PassiveVariant<=ReplaceVariant && PassiveVariant<=DeleteVariant){
                DynamicProgramming[i][j]=PassiveVariant;
                ReverseMoveType[i][j]=PASSIVE;
                continue;
            }
            if (InsertVariant<=DeleteVariant && InsertVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=InsertVariant;
                ReverseMoveType[i][j]=INSERT;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
            if (DeleteVariant<=InsertVariant && DeleteVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=DeleteVariant;
                ReverseMoveType[i][j]=DELETE;
                ReverseMoveParametr1[i][j]=j+1;
                continue;
            }
            if (ReplaceVariant<=DeleteVariant && ReplaceVariant<=InsertVariant){
                DynamicProgramming[i][j]=ReplaceVariant;
                ReverseMoveType[i][j]=REPLACE;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
        }
    cout<<DynamicProgramming[N][M]<<endl;
    AnswerOutput(N,M);
    return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define mp make_pair
#define pf push_front
#define pb push_back
#define fs first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int,int> pint;
const int MAXN=1000;

enum{DELETE,REPLACE,INSERT,PASSIVE};
int ReverseMoveType[MAXN][MAXN];
int ReverseMoveParametr1[MAXN][MAXN];
char ReverseMoveParametr2[MAXN][MAXN];

int DynamicProgramming[MAXN][MAXN];

string A,B;

void AnswerOutput(int i, int j){
    if (i==0 && j==0)
        return;
    if (ReverseMoveType[i][j]==PASSIVE){
        AnswerOutput(i-1,j-1);
        return;
    }
    if (ReverseMoveType[i][j]==INSERT){
        AnswerOutput(i,j-1);
        cout<<"INSERT "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==DELETE){
        AnswerOutput(i-1,j);
        cout<<"DELETE "<<ReverseMoveParametr1[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==REPLACE){
        AnswerOutput(i-1,j-1);
        cout<<"REPLACE "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>A>>B; int N=A.size(); int M=B.size();

    //Dynamic Programming Base
    for (int i=0;i<=N;i++){
        DynamicProgramming[i][0]=i;
        ReverseMoveType[i][0]=PASSIVE;
    }
    for (int i=1;i<=M;i++){
        DynamicProgramming[0][i]=i;
        ReverseMoveType[0][i]=INSERT;
        ReverseMoveParametr1[0][i]=i;
        ReverseMoveParametr2[0][i]=B[i-1];
    }
    for (int i=1;i<=N;i++)
        for (int j=1;j<=M;j++){
            char CurCharA=A[i-1],CurCharB=B[j-1];

            int InsertVariant=DynamicProgramming[i][j-1]+1
                ,DeleteVariant=DynamicProgramming[i-1][j]+1
                ,ReplaceVariant=DynamicProgramming[i-1][j-1]+1,
                 PassiveVariant=DynamicProgramming[i-1][j-1];
            if (CurCharA==CurCharB && PassiveVariant<=InsertVariant && PassiveVariant<=ReplaceVariant && PassiveVariant<=DeleteVariant){
                DynamicProgramming[i][j]=PassiveVariant;
                ReverseMoveType[i][j]=PASSIVE;
                continue;
            }
            if (InsertVariant<=DeleteVariant && InsertVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=InsertVariant;
                ReverseMoveType[i][j]=INSERT;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
            if (DeleteVariant<=InsertVariant && DeleteVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=DeleteVariant;
                ReverseMoveType[i][j]=DELETE;
                ReverseMoveParametr1[i][j]=j+1;
                continue;
            }
            if (ReplaceVariant<=DeleteVariant && ReplaceVariant<=InsertVariant){
                DynamicProgramming[i][j]=ReplaceVariant;
                ReverseMoveType[i][j]=REPLACE;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
        }
    cout<<DynamicProgramming[N][M]<<endl;
    AnswerOutput(N,M);
    return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define mp make_pair
#define pf push_front
#define pb push_back
#define fs first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int,int> pint;
const int MAXN=2000;

enum{DELETE,REPLACE,INSERT,PASSIVE};
int ReverseMoveType[MAXN][MAXN];
int ReverseMoveParametr1[MAXN][MAXN];
char ReverseMoveParametr2[MAXN][MAXN];

int DynamicProgramming[MAXN][MAXN];

string A,B;

void AnswerOutput(int i, int j){
    if (i==0 && j==0)
        return;
    if (ReverseMoveType[i][j]==PASSIVE){
        AnswerOutput(i-1,j-1);
        return;
    }
    if (ReverseMoveType[i][j]==INSERT){
        AnswerOutput(i,j-1);
        cout<<"INSERT "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==DELETE){
        AnswerOutput(i-1,j);
        cout<<"DELETE "<<ReverseMoveParametr1[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==REPLACE){
        AnswerOutput(i-1,j-1);
        cout<<"REPLACE "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>A>>B; int N=A.size(); int M=B.size();

    //Dynamic Programming Base
    for (int i=1;i<=N;i++){
        DynamicProgramming[i][0]=i;
        ReverseMoveType[i][0]=DELETE;
        ReverseMoveParametr1[i][0]=i;
    }
    for (int i=1;i<=M;i++){
        DynamicProgramming[0][i]=i;
        ReverseMoveType[0][i]=INSERT;
        ReverseMoveParametr1[0][i]=i;
        ReverseMoveParametr2[0][i]=B[i-1];
    }
    ReverseMoveType[0][0]=PASSIVE;
    for (int i=1;i<=N;i++)
        for (int j=1;j<=M;j++){
            char CurCharA=A[i-1],CurCharB=B[j-1];

            int InsertVariant=DynamicProgramming[i][j-1]+1
                ,DeleteVariant=DynamicProgramming[i-1][j]+1
                ,ReplaceVariant=DynamicProgramming[i-1][j-1]+1,
                 PassiveVariant=DynamicProgramming[i-1][j-1];
            if (CurCharA==CurCharB && PassiveVariant<=InsertVariant && PassiveVariant<=ReplaceVariant && PassiveVariant<=DeleteVariant){
                DynamicProgramming[i][j]=PassiveVariant;
                ReverseMoveType[i][j]=PASSIVE;
                continue;
            }
            if (InsertVariant<=DeleteVariant && InsertVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=InsertVariant;
                ReverseMoveType[i][j]=INSERT;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
            if (DeleteVariant<=InsertVariant && DeleteVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=DeleteVariant;
                ReverseMoveType[i][j]=DELETE;
                ReverseMoveParametr1[i][j]=j+1;
                continue;
            }
            if (ReplaceVariant<=DeleteVariant && ReplaceVariant<=InsertVariant){
                DynamicProgramming[i][j]=ReplaceVariant;
                ReverseMoveType[i][j]=REPLACE;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
        }
    cout<<DynamicProgramming[N][M]<<endl;
    AnswerOutput(N,M);
    return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define mp make_pair
#define pf push_front
#define pb push_back
#define fs first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int,int> pint;
const int MAXN=1000;

enum{DELETE,REPLACE,INSERT,PASSIVE};
int ReverseMoveType[MAXN][MAXN];
int ReverseMoveParametr1[MAXN][MAXN];
char ReverseMoveParametr2[MAXN][MAXN];

int DynamicProgramming[MAXN][MAXN];

string A,B;

void AnswerOutput(int i, int j){
    if (i==0 && j==0)
        return;
    if (ReverseMoveType[i][j]==PASSIVE){
        AnswerOutput(i-1,j-1);
        return;
    }
    if (ReverseMoveType[i][j]==INSERT){
        AnswerOutput(i,j-1);
        cout<<"INSERT "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==DELETE){
        AnswerOutput(i-1,j);
        cout<<"DELETE "<<ReverseMoveParametr1[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==REPLACE){
        AnswerOutput(i-1,j-1);
        cout<<"REPLACE "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>A>>B; int N=A.size(); int M=B.size();

    //Dynamic Programming Base
    for (int i=0;i<=N;i++){
        DynamicProgramming[i][0]=i;
        ReverseMoveType[i][0]=PASSIVE;
    }
    for (int i=1;i<=M;i++){
        DynamicProgramming[0][i]=i;
        ReverseMoveType[0][i]=INSERT;
        ReverseMoveParametr1[0][i]=i;
        ReverseMoveParametr2[0][i]=B[i-1];
    }
    for (int i=1;i<=N;i++)
        for (int j=1;j<=M;j++){
            char CurCharA=A[i-1],CurCharB=B[j-1];

            int InsertVariant=DynamicProgramming[i][j-1]+1
                ,DeleteVariant=DynamicProgramming[i-1][j]+1
                ,ReplaceVariant=DynamicProgramming[i-1][j-1]+1,
                 PassiveVariant=DynamicProgramming[i-1][j-1];
            if (CurCharA==CurCharB && PassiveVariant<=InsertVariant && PassiveVariant<=ReplaceVariant && PassiveVariant<=DeleteVariant){
                DynamicProgramming[i][j]=PassiveVariant;
                ReverseMoveType[i][j]=PASSIVE;
                continue;
            }
            if (InsertVariant<=DeleteVariant && InsertVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=InsertVariant;
                ReverseMoveType[i][j]=INSERT;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
            if (DeleteVariant<=InsertVariant && DeleteVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=DeleteVariant;
                ReverseMoveType[i][j]=DELETE;
                ReverseMoveParametr1[i][j]=j;
                continue;
            }
            if (ReplaceVariant<=DeleteVariant && ReplaceVariant<=InsertVariant){
                DynamicProgramming[i][j]=ReplaceVariant;
                ReverseMoveType[i][j]=REPLACE;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
        }
    cout<<DynamicProgramming[N][M]<<endl;
    AnswerOutput(N,M);
    return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define mp make_pair
#define pf push_front
#define pb push_back
#define fs first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int,int> pint;
const int MAXN=1000;

enum{DELETE,REPLACE,INSERT,PASSIVE};
int ReverseMoveType[MAXN][MAXN];
int ReverseMoveParametr1[MAXN][MAXN];
char ReverseMoveParametr2[MAXN][MAXN];

int DynamicProgramming[MAXN][MAXN];

string A,B;

void AnswerOutput(int i, int j){
    if (i==0 && j==0)
        return;
    if (ReverseMoveType[i][j]==PASSIVE){
        AnswerOutput(i-1,j-1);
        return;
    }
    if (ReverseMoveType[i][j]==INSERT){
        AnswerOutput(i,j-1);
        cout<<"INSERT "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==DELETE){
        AnswerOutput(i-1,j);
        cout<<"DELETE "<<ReverseMoveParametr1[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==REPLACE){
        AnswerOutput(i-1,j-1);
        cout<<"REPLACE "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>A>>B; int N=A.size(); int M=B.size();

    //Dynamic Programming Base
    for (int i=0;i<=N;i++){
        DynamicProgramming[i][0]=i;
        ReverseMoveType[i][0]=DELETE;
        ReverseMoveParametr1[i][0]=i;
    }
    for (int i=1;i<=M;i++){
        DynamicProgramming[0][i]=i;
        ReverseMoveType[0][i]=INSERT;
        ReverseMoveParametr1[0][i]=i;
        ReverseMoveParametr2[0][i]=B[i-1];
    }
    ReverseMoveType[i][i]=PASSIVE;
    for (int i=1;i<=N;i++)
        for (int j=1;j<=M;j++){
            char CurCharA=A[i-1],CurCharB=B[j-1];

            int InsertVariant=DynamicProgramming[i][j-1]+1
                ,DeleteVariant=DynamicProgramming[i-1][j]+1
                ,ReplaceVariant=DynamicProgramming[i-1][j-1]+1,
                 PassiveVariant=DynamicProgramming[i-1][j-1];
            if (CurCharA==CurCharB && PassiveVariant<=InsertVariant && PassiveVariant<=ReplaceVariant && PassiveVariant<=DeleteVariant){
                DynamicProgramming[i][j]=PassiveVariant;
                ReverseMoveType[i][j]=PASSIVE;
                continue;
            }
            if (InsertVariant<=DeleteVariant && InsertVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=InsertVariant;
                ReverseMoveType[i][j]=INSERT;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
            if (DeleteVariant<=InsertVariant && DeleteVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=DeleteVariant;
                ReverseMoveType[i][j]=DELETE;
                ReverseMoveParametr1[i][j]=j+1;
                continue;
            }
            if (ReplaceVariant<=DeleteVariant && ReplaceVariant<=InsertVariant){
                DynamicProgramming[i][j]=ReplaceVariant;
                ReverseMoveType[i][j]=REPLACE;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
        }
    cout<<DynamicProgramming[N][M]<<endl;
    AnswerOutput(N,M);
    return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define mp make_pair
#define pf push_front
#define pb push_back
#define fs first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int,int> pint;
const int MAXN=1000;

enum{DELETE,REPLACE,INSERT,PASSIVE};
int ReverseMoveType[MAXN][MAXN];
int ReverseMoveParametr1[MAXN][MAXN];
char ReverseMoveParametr2[MAXN][MAXN];

int DynamicProgramming[MAXN][MAXN];

string A,B;

void AnswerOutput(int i, int j){
    if (i==0 && j==0)
        return;
    if (ReverseMoveType[i][j]==PASSIVE){
        AnswerOutput(i-1,j-1);
        return;
    }
    if (ReverseMoveType[i][j]==INSERT){
        AnswerOutput(i,j-1);
        cout<<"INSERT "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==DELETE){
        AnswerOutput(i-1,j);
        cout<<"DELETE "<<ReverseMoveParametr1[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==REPLACE){
        AnswerOutput(i-1,j-1);
        cout<<"REPLACE "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>A>>B; int N=A.size(); int M=B.size();

    //Dynamic Programming Base
    for (int i=0;i<=N;i++){
        DynamicProgramming[i][0]=i;
        ReverseMoveType[i][0]=PASSIVE;
    }
    for (int i=1;i<=M;i++){
        DynamicProgramming[0][i]=i;
        ReverseMoveType[0][i]=INSERT;
        ReverseMoveParametr1[0][i]=i;
        ReverseMoveParametr2[0][i]=B[i-1];
    }
    for (int i=1;i<=N;i++)
        for (int j=1;j<=M;j++){
            char CurCharA=A[i-1],CurCharB=B[j-1];

            int InsertVariant=DynamicProgramming[i][j-1]+1
                ,DeleteVariant=DynamicProgramming[i-1][j]+1
                ,ReplaceVariant=DynamicProgramming[i-1][j-1]+1,
                 PassiveVariant=DynamicProgramming[i-1][j-1];
            if (CurCharA==CurCharB && PassiveVariant<=InsertVariant && PassiveVariant<=ReplaceVariant && PassiveVariant<=DeleteVariant){
                DynamicProgramming[i][j]=PassiveVariant;
                ReverseMoveType[i][j]=PASSIVE;
                continue;
            }
            if (InsertVariant<=DeleteVariant && InsertVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=InsertVariant;
                ReverseMoveType[i][j]=INSERT;
                ReverseMoveParametr1[i][j]=j-1;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
            if (DeleteVariant<=InsertVariant && DeleteVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=DeleteVariant;
                ReverseMoveType[i][j]=DELETE;
                ReverseMoveParametr1[i][j]=j;
                continue;
            }
            if (ReplaceVariant<=DeleteVariant && ReplaceVariant<=InsertVariant){
                DynamicProgramming[i][j]=ReplaceVariant;
                ReverseMoveType[i][j]=REPLACE;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
        }
    cout<<DynamicProgramming[N][M]<<endl;
    AnswerOutput(N,M);
    return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define mp make_pair
#define pf push_front
#define pb push_back
#define fs first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int,int> pint;
const int MAXN=2000;

enum{DELETE,REPLACE,INSERT,PASSIVE};
int ReverseMoveType[MAXN][MAXN];
int ReverseMoveParametr1[MAXN][MAXN];
char ReverseMoveParametr2[MAXN][MAXN];

int DynamicProgramming[MAXN][MAXN];

string A,B;

void AnswerOutput(int i, int j){
    if (i==0 && j==0)
        return;
    if (ReverseMoveType[i][j]==PASSIVE){
        AnswerOutput(i-1,j-1);
        return;
    }
    if (ReverseMoveType[i][j]==INSERT){
        AnswerOutput(i,j-1);
        cout<<"INSERT "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==DELETE){
        AnswerOutput(i-1,j);
        cout<<"DELETE "<<ReverseMoveParametr1[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==REPLACE){
        AnswerOutput(i-1,j-1);
        cout<<"REPLACE "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>A>>B; int N=A.size(); int M=B.size();

    //Dynamic Programming Base
    for (int i=0;i<=N;i++){
        DynamicProgramming[i][0]=i;
        ReverseMoveType[i][0]=DELETE;
        ReverseMoveParametr1[i][0]=i;
    }
    for (int i=1;i<=M;i++){
        DynamicProgramming[0][i]=i;
        ReverseMoveType[0][i]=INSERT;
        ReverseMoveParametr1[0][i]=i+1;
        ReverseMoveParametr2[0][i]=B[i-1];
    }
    ReverseMoveType[0][0]=PASSIVE;
    for (int i=1;i<=N;i++)
        for (int j=1;j<=M;j++){
            char CurCharA=A[i-1],CurCharB=B[j-1];

            int InsertVariant=DynamicProgramming[i][j-1]+1
                ,DeleteVariant=DynamicProgramming[i-1][j]+1
                ,ReplaceVariant=DynamicProgramming[i-1][j-1]+1,
                 PassiveVariant=DynamicProgramming[i-1][j-1];
            if (CurCharA==CurCharB && PassiveVariant<=InsertVariant && PassiveVariant<=ReplaceVariant && PassiveVariant<=DeleteVariant){
                DynamicProgramming[i][j]=PassiveVariant;
                ReverseMoveType[i][j]=PASSIVE;
                continue;
            }
            if (InsertVariant<=DeleteVariant && InsertVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=InsertVariant;
                ReverseMoveType[i][j]=INSERT;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
            if (DeleteVariant<=InsertVariant && DeleteVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=DeleteVariant;
                ReverseMoveType[i][j]=DELETE;
                ReverseMoveParametr1[i][j]=j+1;
                continue;
            }
            if (ReplaceVariant<=DeleteVariant && ReplaceVariant<=InsertVariant){
                DynamicProgramming[i][j]=ReplaceVariant;
                ReverseMoveType[i][j]=REPLACE;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
        }
    cout<<DynamicProgramming[N][M]<<endl;
    AnswerOutput(N,M);
    return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define mp make_pair
#define pf push_front
#define pb push_back
#define fs first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int,int> pint;
const int MAXN=1000;

enum{DELETE,REPLACE,INSERT,PASSIVE};
int ReverseMoveType[MAXN][MAXN];
int ReverseMoveParametr1[MAXN][MAXN];
char ReverseMoveParametr2[MAXN][MAXN];

int DynamicProgramming[MAXN][MAXN];

string A,B;

void AnswerOutput(int i, int j){
    if (i==0 && j==0)
        return;
    if (ReverseMoveType[i][j]==PASSIVE){
        AnswerOutput(i-1,j-1);
        return;
    }
    if (ReverseMoveType[i][j]==INSERT){
        AnswerOutput(i,j-1);
        cout<<"INSERT "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==DELETE){
        AnswerOutput(i-1,j);
        cout<<"DELETE "<<ReverseMoveParametr1[i][j]<<endl;
        return;
    }
    if (ReverseMoveType[i][j]==REPLACE){
        AnswerOutput(i-1,j-1);
        cout<<"REPLACE "<<ReverseMoveParametr1[i][j]<<" "<<ReverseMoveParametr2[i][j]<<endl;
        return;
    }
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>A>>B; int N=A.size(); int M=B.size();

    //Dynamic Programming Base
    for (int i=0;i<=N;i++){
        DynamicProgramming[i][0]=i;
        ReverseMoveType[i][0]=DELETE;
        ReverseMoveParametr1[i][0]=i;
    }
    for (int i=1;i<=M;i++){
        DynamicProgramming[0][i]=i;
        ReverseMoveType[0][i]=INSERT;
        ReverseMoveParametr1[0][i]=i;
        ReverseMoveParametr2[0][i]=B[i-1];
    }
    ReverseMoveType[0][0]=PASSIVE;
    for (int i=1;i<=N;i++)
        for (int j=1;j<=M;j++){
            char CurCharA=A[i-1],CurCharB=B[j-1];

            int InsertVariant=DynamicProgramming[i][j-1]+1
                ,DeleteVariant=DynamicProgramming[i-1][j]+1
                ,ReplaceVariant=DynamicProgramming[i-1][j-1]+1,
                 PassiveVariant=DynamicProgramming[i-1][j-1];
            if (CurCharA==CurCharB && PassiveVariant<=InsertVariant && PassiveVariant<=ReplaceVariant && PassiveVariant<=DeleteVariant){
                DynamicProgramming[i][j]=PassiveVariant;
                ReverseMoveType[i][j]=PASSIVE;
                continue;
            }
            if (InsertVariant<=DeleteVariant && InsertVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=InsertVariant;
                ReverseMoveType[i][j]=INSERT;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
            if (DeleteVariant<=InsertVariant && DeleteVariant<=ReplaceVariant){
                DynamicProgramming[i][j]=DeleteVariant;
                ReverseMoveType[i][j]=DELETE;
                ReverseMoveParametr1[i][j]=j+1;
                continue;
            }
            if (ReplaceVariant<=DeleteVariant && ReplaceVariant<=InsertVariant){
                DynamicProgramming[i][j]=ReplaceVariant;
                ReverseMoveType[i][j]=REPLACE;
                ReverseMoveParametr1[i][j]=j;
                ReverseMoveParametr2[i][j]=CurCharB;
                continue;
            }
        }
    cout<<DynamicProgramming[N][M]<<endl;
    AnswerOutput(N,M);
    return 0;
}


#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int arr[1001][1001] = { 0 };

struct Action
{
	string operatio;
	int index;
	char ch;
};
int main()
{
	string a, b;
	cin >> a >> b;
	for (int col = 0; col <= a.size(); col++)
	{
		arr[0][col] = col;
	}
	for (int row = 0; row <= b.size(); row++)
	{
		arr[row][0] = row;
	}

	for (int row = 1; row <= b.size(); row++)
	{
		for (int col = 1; col <= a.size(); col++)
		{
			if (a[col - 1] == b[row - 1])
			{
				arr[row][col] = arr[row - 1][col - 1];
			}
			else
			{
				arr[row][col] = min(arr[row - 1][col - 1], min(arr[row - 1][col], arr[row][col - 1])) + 1;
			}
		}
	}
	int row = b.size();
	int col = a.size();
	cout << arr[row][col] << endl;
	vector<Action> v;
	while (true)
	{
		if (row == 0 && col == 0)
		{
			break;
		}
		if (col > 0 && row > 0)
		{
			if (a[col - 1] == b[row - 1])
			{
				row--;
				col--;
			}
			else
			{
				int val = min(arr[row - 1][col - 1], min(arr[row - 1][col], arr[row][col - 1]));
				Action ac;
				if (val == arr[row - 1][col - 1])
				{
					ac.operatio = "REPLACE";
					ac.index = row;
					ac.ch = b[row - 1];

					row--;
					col--;
				}
				else if (val == arr[row - 1][col])
				{
					ac.operatio = "INSERT";
					ac.index = row;
					ac.ch = b[row - 1];

					row--;
				}
				else
				{
					ac.operatio = "DELETE";
					ac.index = col;
					col--;
				}
				v.push_back(ac);
			}
		}
		else if (row > 0)
		{
			Action ac;
			ac.operatio = "INSERT";
			ac.index = row;
			ac.ch = b[row - 1];

			row--;
			v.push_back(ac);
		}
		else if (col > 0)
		{
			Action ac;
			ac.operatio = "DELETE";
			ac.index = col;

			col--;
			v.push_back(ac);
		}
	}

	for (int i = v.size() - 1; i >= 0; i--)
	{
		if(v[i].operatio == "DELETE")
			cout << v[i].operatio << " " << v[i].index << endl;
		else
			cout << v[i].operatio << " " << v[i].index << " " << v[i].ch << endl;
	}
}


#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int arr[1001][1001] = { 0 };

struct Action
{
	string operatio;
	int index;
	char ch;
};
int main()
{
	string a, b;
	cin >> a >> b;
	for (int col = 0; col <= a.size(); col++)
	{
		arr[0][col] = col;
	}
	for (int row = 0; row <= b.size(); row++)
	{
		arr[row][0] = row;
	}

	for (int row = 1; row <= b.size(); row++)
	{
		for (int col = 1; col <= a.size(); col++)
		{
			if (a[col - 1] == b[row - 1])
			{
				arr[row][col] = arr[row - 1][col - 1];
			}
			else
			{
				arr[row][col] = min(arr[row - 1][col - 1], min(arr[row - 1][col], arr[row][col - 1])) + 1;
			}
		}
	}
	int row = b.size();
	int col = a.size();
	cout << arr[row][col] << endl;
	vector<Action> v;
	while (true)
	{
		if (row == 0 && col == 0)
		{
			break;
		}
		if (col > 0 && row > 0)
		{
			if (a[col - 1] == b[row - 1])
			{
				row--;
				col--;
			}
			else
			{
				int val = min(arr[row - 1][col - 1], min(arr[row - 1][col], arr[row][col - 1]));
				Action ac;
				if (val == arr[row - 1][col - 1])
				{
					ac.operatio = "REPLACE";
					ac.index = row;
					ac.ch = b[row - 1];

					row--;
					col--;
				}
				else if (val == arr[row - 1][col])
				{
					ac.operatio = "INSERT";
					ac.index = row;
					ac.ch = b[row - 1];

					row--;
				}
				else
				{
					ac.operatio = "DELETE";
					ac.index = col;
					ac.ch = b[col - 1];

					col--;
				}
				v.push_back(ac);
			}
		}
		else if (row > 0)
		{
			Action ac;
			ac.operatio = "INSERT";
			ac.index = row;
			ac.ch = b[row - 1];

			row--;
			v.push_back(ac);
		}
		else if (col > 0)
		{
			Action ac;
			ac.operatio = "DELETE";
			ac.index = col;
			ac.ch = b[col - 1];

			col--;
			v.push_back(ac);
		}
	}

	for (int i = v.size() - 1; i >= 0; i--)
	{
		cout << v[i].operatio << " " << v[i].index << " " << v[i].ch << endl;
	}
}


#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int arr[1001][1001] = { 0 };

struct Action
{
	string operatio;
	int index;
	char ch;
};
int main()
{
	string a, b;
	cin >> a >> b;
	for (int col = 0; col <= a.size(); col++)
	{
		arr[0][col] = col;
	}
	for (int row = 0; row <= b.size(); row++)
	{
		arr[row][0] = row;
	}

	for (int row = 1; row <= b.size(); row++)
	{
		for (int col = 1; col <= a.size(); col++)
		{
			if (a[col - 1] == b[row - 1])
			{
				arr[row][col] = arr[row - 1][col - 1];
			}
			else
			{
				arr[row][col] = min(arr[row - 1][col - 1], min(arr[row - 1][col], arr[row][col - 1])) + 1;
			}
		}
	}
	int row = b.size();
	int col = a.size();
	cout << arr[row][col] << endl;
	vector<Action> v;
	while (true)
	{
		if (row == 0 && col == 0)
		{
			break;
		}
		if (col > 0 && row > 0)
		{
			if (a[col - 1] == b[row - 1])
			{
				row--;
				col--;
			}
			else
			{
				int val = min(arr[row - 1][col - 1], min(arr[row - 1][col], arr[row][col - 1]));
				Action ac;
				if (val == arr[row - 1][col - 1])
				{
					ac.operatio = "REPLACE";
					ac.index = row;
					ac.ch = b[row - 1];

					row--;
					col--;
				}
				else if (val == arr[row - 1][col])
				{
					ac.operatio = "INSERT";
					ac.index = row;
					ac.ch = b[row - 1];

					row--;
				}
				else
				{
					ac.operatio = "DELETE";
					ac.index = row;

					col--;
				}
				v.push_back(ac);
			}
		}
		else if (row > 0)
		{
			Action ac;
			ac.operatio = "INSERT";
			ac.index = row;
			ac.ch = b[row - 1];

			row--;
			v.push_back(ac);
		}
		else if (col > 0)
		{
			Action ac;
			ac.operatio = "DELETE";
			ac.index = row;

			col--;
			v.push_back(ac);
		}
	}

	for (int i = v.size() - 1; i >= 0; i--)
	{
		if(v[i].operatio == "DELETE")
			cout << v[i].operatio << " " << v[i].index << endl;
		else
			cout << v[i].operatio << " " << v[i].index << " " << v[i].ch << endl;
	}
}


#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int arr[1001][1001] = { 0 };

struct Action
{
	string operatio;
	int index;
	char ch;
};
int main()
{
	string a, b;
	cin >> a >> b;
	for (int col = 0; col <= a.size(); col++)
	{
		arr[0][col] = col;
	}
	for (int row = 0; row <= b.size(); row++)
	{
		arr[row][0] = row;
	}

	for (int row = 1; row <= b.size(); row++)
	{
		for (int col = 1; col <= a.size(); col++)
		{
			if (a[col - 1] == b[row - 1])
			{
				arr[row][col] = arr[row - 1][col - 1];
			}
			else
			{
				arr[row][col] = min(arr[row - 1][col - 1], min(arr[row - 1][col], arr[row][col - 1])) + 1;
			}
		}
	}
	int row = b.size();
	int col = a.size();
	cout << arr[row][col] << endl;
	vector<Action> v;
	while (true)
	{
		if (row == 0 && col == 0)
		{
			break;
		}
		if (col > 0 && row > 0)
		{
			if (a[col - 1] == b[row - 1])
			{
				row--;
				col--;
			}
			else
			{
				int val = min(arr[row - 1][col - 1], min(arr[row - 1][col], arr[row][col - 1]));
				Action ac;
				if (val == arr[row - 1][col - 1])
				{
					ac.operatio = "REPLACE";
					ac.index = row;
					ac.ch = b[row - 1];

					row--;
					col--;
				}
				else if (val == arr[row - 1][col])
				{
					ac.operatio = "INSERT";
					ac.index = row;
					ac.ch = b[row - 1];

					row--;
				}
				else
				{
					ac.operatio = "DELETE";
					ac.index = row;
					if (ac.index == 0)
						ac.index = 1;
					col--;
				}
				v.push_back(ac);
			}
		}
		else if (row > 0)
		{
			Action ac;
			ac.operatio = "INSERT";
			ac.index = row;
			ac.ch = b[row - 1];

			row--;
			v.push_back(ac);
		}
		else if (col > 0)
		{
			Action ac;
			ac.operatio = "DELETE";
			ac.index = row;
			if (ac.index == 0)
				ac.index = 1;

			col--;
			v.push_back(ac);
		}
	}

	for (int i = v.size() - 1; i >= 0; i--)
	{
		if(v[i].operatio == "DELETE")
			cout << v[i].operatio << " " << v[i].index << endl;
		else
			cout << v[i].operatio << " " << v[i].index << " " << v[i].ch << endl;
	}
}


#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int arr[1001][1001] = { 0 };

struct Action
{
	string operatio;
	int index;
	char ch;
};
int main()
{
	string a, b;
	cin >> a >> b;
	for (int col = 0; col <= a.size(); col++)
	{
		arr[0][col] = col;
	}
	for (int row = 0; row <= b.size(); row++)
	{
		arr[row][0] = row;
	}

	for (int row = 1; row <= b.size(); row++)
	{
		for (int col = 1; col <= a.size(); col++)
		{
			if (a[col - 1] == b[row - 1])
			{
				arr[row][col] = arr[row - 1][col - 1];
			}
			else
			{
				arr[row][col] = min(arr[row - 1][col - 1], min(arr[row - 1][col], arr[row][col - 1])) + 1;
			}
		}
	}
	int row = b.size();
	int col = a.size();
	cout << arr[row][col] << endl;
	vector<Action> v;
	while (true)
	{
		if (row == 0 && col == 0)
		{
			break;
		}
		if (col > 0 && row > 0)
		{
			if (a[col - 1] == b[row - 1])
			{
				row--;
				col--;
			}
			else
			{
				int val = min(arr[row - 1][col - 1], min(arr[row - 1][col], arr[row][col - 1]));
				Action ac;
				if (val == arr[row][col - 1])
				{
					ac.operatio = "DELETE";
					ac.index = row+1;
					col--;
				}
				else if (val == arr[row - 1][col])
				{
					ac.operatio = "INSERT";
					ac.index = row;
					ac.ch = b[row - 1];

					row--;
				}
				else if (val == arr[row - 1][col - 1])
				{
					ac.operatio = "REPLACE";
					ac.index = row;
					ac.ch = b[row - 1];

					row--;
					col--;
				}
				v.push_back(ac);
			}
		}
		else if (row > 0)
		{
			Action ac;
			ac.operatio = "INSERT";
			ac.index = row;
			ac.ch = b[row - 1];

			row--;
			v.push_back(ac);
		}
		else if (col > 0)
		{
			Action ac;
			ac.operatio = "DELETE";
			ac.index = row+1;

			col--;
			v.push_back(ac);
		}
	}

	for (int i = v.size() - 1; i >= 0; i--)
	{
		if(v[i].operatio == "DELETE")
			cout << v[i].operatio << " " << v[i].index << endl;
		else
			cout << v[i].operatio << " " << v[i].index << " " << v[i].ch << endl;
	}
}


#include <stdio.h>
#include <sstream>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cassert>
#include <string.h>
using namespace std;
#pragma comment(linker, "/STACK:20000000")

typedef vector<int> vi;
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()

string problem_name = "a";

void init(){
  freopen((problem_name+".in").c_str(),"rt",stdin);
 // freopen((problem_name+".out").c_str(),"wt",stdout);
}

int dp[1111][1111];
string s, t;
int oo=1010100;
int next[1111][1111];
int pos[1111][1111];
char ch[1111][1111];
int go(int a, int b)
{
	if (a>=sz(s) && b>=sz(t)) return 0;
	if (dp[a][b]!=-1) return dp[a][b];
	int res=oo;
	int cur;
	if (a<sz(s))
	{
		cur=1+go(a+1,b);
		if (cur<res)
		{
			res=cur;
			next[a][b]=1;
			pos[a][b]=a;
		}
	}
	if (b<sz(t))
	{
		cur=1+go(a,b+1);
		if (cur<res)
		{
			res=cur;
			next[a][b]=2;
			pos[a][b]=b;
		}
	}
	if (a<sz(s) && b<sz(t))
	{
		cur = 1+go(a+1,b+1);

		if (cur<res)
		{
			res=cur;
			next[a][b]=3;
			pos[a][b]=a;
		}

		if (s[a]==t[b])
			cur=go(a+1,b+1);
		if (cur<res)
		{
			res=cur;
			next[a][b]=4;
			pos[a][b]=a;
		}
	}

	return dp[a][b] = res;
}

int main()
{
    //init();

	cin >> s >> t;
	memset(dp,-1,sizeof(dp));
	printf("%d\n",go(0,0));
	int D=0,I=0;

	int a=0,b=0;
	while (a<sz(s) || b<sz(t))
	{
		if (next[a][b]==1)
		{
			printf("DELETE %d\n",a-D+I+1);
			D++;
			a++;
		} else
		if (next[a][b]==2)
		{
			printf("INSERT %d %c\n",a-D+I+1,t[b]);
			I++;
			b++;
		} else
		if (next[a][b]==3)
		{
			printf("REPLACE %d %c\n",a-D+I+1,t[b]);
			a++;
			b++;
		} else
		if (next[a][b]==4)
		{
			a++;
			b++;
		}
	}

	return 0;
}


#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
vector<string> route;
int levenshtein(string x,string y)
{
    int n = x.size();
    int m = y.size();
    vector<vector<int> > dp(n + 1,vector<int>(m + 1));
    vector<vector<char> > path(n + 1,vector<char>(m + 1));
    for(int i = 0; i <= n; i++)
    {
        dp[i][0] = i;
        path[i][0] = 'D';
    }
    for(int i = 0; i <= m; i++)
    {
        dp[0][i] = i;
        path[0][i] = 'I';
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            int cost = x[i - 1] != y[j - 1];
            path[i][j] = cost ? 'R' : 'M';
            dp[i][j] = 1000000;
            dp[i][j] = dp[i-1][j-1] + cost;
            if(dp[i][j - 1] + 1 < dp[i][j])
            {
                dp[i][j] = dp[i][j - 1] + 1;
                path[i][j] = 'I';
            }
            if (dp[i - 1][j] + 1 < dp[i][j])
            {
                dp[i][j] = dp[i - 1][j] + 1;
                path[i][j] = 'D';
            }
        }
    }
    int k = dp[n][m];
    int i = n;
    int j = m;
    while(k > 0)
    {
        char c = path[i][j];
        char buf[10] = {0};
        string str;
        if(dp[i][j] == dp[i][j-1]+1)
        {
            itoa(i + 1,buf,10);
            str += "INSERT ";
            str += buf;
            str += " ";
            str += y[j - 1];
            j--;
            k--;
        }
        else
        {
            if(dp[i][j] == dp[i-1][j]+1)
            {
                itoa(i,buf,10);
                str += "DELETE ";
                str += buf;
                i--;
                k--;
            }
            else if( dp[i][j]==dp[i-1][j-1]+1)
            {
                str += "REPLACE ";
                itoa(i,buf,10);
                str += buf;
                str += " ";
                str += y[j - 1];
                k--;
            }
            i--;
            j--;
        }
        if(!str.empty())
            route.push_back(str);
    }
    return dp[n][m];
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("testData.txt","w",stdout);
    string s1,s2;
    cin >> s1 >> s2;
    printf("%d\n",levenshtein(s1,s2));
    for(int i = 0; i < route.size(); i++)
    {
        printf("%s\n",route[route.size() - 1 - i].c_str());
    }
    return 0;
}