#include <bits/stdc++.h>
using namespace std;

struct Node{
    int val;
    bool del;
    pair<int, int> prv;
};

const int N = 200005;
const int M = 15;
Node dp[N][M];

int main()
{
    string T;
    cin >> T;
    string S;
    cin >> S;
    int n, m;
    n = T.size(); m = S.size();

    for(int j = 0; j < m; ++j)
        dp[0][j].prv.first = dp[0][j].prv.second = -1;

    if(S[0] == T[0]){
        dp[0][0].val = 1;
        dp[0][0].del = true;
    }
    for(int i = 1; i < n; ++i){
        dp[i][0].prv = {i - 1, 0};
        dp[i][0] = dp[i - 1][0];
        if(S[0] == T[i]){
            dp[i][0].val++;
            dp[i][0].del = true;
        }
        for(int j = 1; j < m; ++j){
            if(S[j] == T[i]){
                if(dp[i - 1][j - 1].val <= dp[i - 1][j].val + 1){
                    dp[i][j].del = false;
                    dp[i][j].val = dp[i - 1][j - 1].val;
                    dp[i][j].prv = {i - 1, j - 1};
                }else{
                    dp[i][j].del = true;
                    dp[i][j].val = dp[i - 1][j].val + 1;
                    dp[i][j].prv = {i - 1, j};
                }
            }else{
                dp[i][j].val = dp[i - 1][j].val;
                dp[i][j].prv = {i - 1, j};
            }
        }
    }

    Node cur = dp[n - 1][m - 1];
    while(1){
        if(cur.del){
            T[cur.prv.first + 1] = '*';
        }
        if(cur.prv == pair<int, int>(-1, -1))
            break;
        cur = dp[cur.prv.first][cur.prv.second];
    }

    cout << dp[n - 1][m - 1].val << "\n";
    cout << T << "\n";
    return 0;
}