There is a string *s*, consisting of capital Latin letters. Let's denote its current length as |*s*|. During one move it is allowed to apply one of the following operations to it: 
 -  INSERT *pos* *ch* — insert a letter *ch* in the string *s* in the position *pos* (1 ≤ *pos* ≤ |*s*| + 1, *A* ≤ *ch* ≤ *Z*). The letter *ch* becomes the *pos*-th symbol of the string *s*, at that the letters shift aside and the length of the string increases by 1. -  DELETE *pos* — delete a character number *pos* (1 ≤ *pos* ≤ |*s*|) from the string *s*. At that the letters shift together and the length of the string decreases by 1. -  REPLACE *pos* *ch* — the letter in the position *pos* of the line *s* is replaced by *ch* (1 ≤ *pos* ≤ |*s*|, *A* ≤ *ch* ≤ *Z*). At that the length of the string does not change. 
Your task is to find in which minimal number of moves one can get a *t* string from an *s* string. You should also find the sequence of actions leading to the required results.
The first line contains *s*, the second line contains *t*. The lines consist only of capital Latin letters, their lengths are positive numbers from 1 to 1000.
# '''
# this one works but delete and insert is reversed I think
def main():
    s = input()
    t = input()
    solve(s, t)


def solve(word1, word2):
    word1_len, word2_len = len(word1), len(word2)

    dp = [[0 for _ in range(word1_len + 1)] for _ in range(word2_len + 1)]

    for row in range(word2_len, -1, -1):
        for col in range(word1_len, -1, -1):
            if row == word2_len and col == word1_len: #zero
                dp[row][col] = 0
            elif row == word2_len:
                dp[row][col] = word1_len - col
            elif col == word1_len:
                dp[row][col] = word2_len - row
            else:
                # res = None
                if word1[col] == word2[row]:
                    dp[row][col] = dp[row + 1][col + 1]
                else:
                    delete = dp[row + 1][col]
                    insert = dp[row][col + 1]
                    replace = dp[row + 1][col + 1]
                    dp[row][col] = min(delete, insert, replace) + 1
    
    # print(dp)
    # for row in dp:
    #     print(row)
    # print(dp)

    curr_length = min_length = dp[0][0]
    print(min_length, end = "")
    i, j = 0, 0

    while dp[i][j] > 0:
        # if word1[i] == word2[j]:
        if word2[i] == word1[j]:
            # print("SKIP I ", i, " J ", j, " word1 ", word1, " word2 ", word2)
            i,j = i + 1, j + 1
        else:
            delete, delete_i, delete_j = dp[i + 1][j], i + 1, j
            insert, insert_i, insert_j = dp[i][j + 1], i, j + 1
            replace, replace_i, replace_j = dp[i + 1][j + 1], i + 1, j + 1

            min_next = min(delete, insert, replace)
            if min_next == replace:
                print("\nREPLACE", i + 1, word2[i], end = "")
                i, j = replace_i, replace_j
            elif min_next == delete:
                # print("DELETE")
                print("\nINSERT", i + 1, word2[i], end = "")
                i, j = delete_i, delete_j
            elif min_next == insert:
                # print("INSERT")
                print("\nDELETE", j + 1, word1[j], end = "")
                i, j = insert_i, insert_j
            
            # if min_next == delete:
            #     # print("DELETE")
            #     print("INSERT", i + 1, word2[i])
            #     i, j = delete_i, delete_j
            # elif min_next == insert:
            #     # print("INSERT")
            #     print("DELETE", j + 1, word1[j])
            #     i, j = insert_i, insert_j
            # elif min_next == replace:
            #     print("REPLACE", i + 1, word2[i])
            #     i, j = replace_i, replace_j

    # print(dp)
    # for row in dp:
    #     print(row)
    
    # print(dp)


            

    

if __name__ == "__main__":
    main()



# '''