#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

const ll N = 200000,
            M = 10;
string x, y;
ll dp[N][M] = {}, tmp;
bool vis[N][M] = {}, s[N] = {};

ll ans(int i, int j){
    if (vis[i][j]) return dp[i][j];
    vis[i][j] = 1;
    if (i == 0) return (dp[i][j] = (x[i] == y[j]));
    dp[i][j] = ans(i - 1, j);
    if (x[i] == y[j]) {
        ++dp[i][j];
        if (j != 0) dp[i][j] = min(dp[i][j], ans(i - 1, j - 1));
    }
    return dp[i][j];
}

void obrisi(int i, int j){
    if (i < 0 || j < 0) return;
    if (i == 0){
        if (dp[i][j]) x[i] = '*';
        return;
    }
    if (x[i] != y[j]) obrisi(i - 1, j);
    else if (dp[i][j] == dp[i - 1][j] + 1) {
        obrisi(i - 1, j);
        x[i] = '*';
    }
    else obrisi(i - 1, j - 1);
}

void solve(){
    cin >> x >> y;
    cout << ans(x.size() - 1, y.size() - 1) << endl;
    obrisi(x.size() - 1, y.size() - 1);
    cout << x << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

    return 0;
}