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

using ll = long long;
using ld = long double;

const int N = 200000;

int dp[N+5][10];
tuple <int, int, int> od[N+5][10];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    for(int i=1; i<=n; i++) for(int j=0; j<m; j++) dp[i][j] = n + 5;
    for(int j=1; j<m; j++) dp[0][j] = n + 5;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(s[i] != t[j]){
                if(dp[i+1][j] > dp[i][j]){
                    dp[i+1][j] = dp[i][j];
                    od[i+1][j] = {i, j, 0};
                }
            }
            else{
                if(j+1 < m && dp[i+1][j+1] > dp[i][j]){
                    dp[i+1][j+1] = dp[i][j];
                    od[i+1][j+1] = {i, j, 0};
                }
                if(dp[i+1][j] > dp[i][j] + 1){
                    dp[i+1][j] = dp[i][j] + 1;
                    od[i+1][j] = {i, j, 1};
                }
            }
        }
    }
    int mn = n + 5;
    for(int i=0; i<m; i++) mn = min(mn, dp[n][i]);
    pair <int, int> poc;
    for(int i=0; i<m; i++) if(mn == dp[n][i]) poc = {n, i};
    while(poc.first > 0){
        int i, m, d;
        tie(i, m, d) = od[poc.first][poc.second];
        poc = {i, m};
        if(d) s[i] = '*';
    }
    cout << mn << "\n";
    cout << s << "\n";
    return 0;
}