#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (long long)1e18
#define MOD (long long)(1e9+7)
#define sz(x) ((int)x.size())
#define K int(12000)
#define X real()
#define Y imag()
#define F first
#define S second
#define EPS 1e-6
#define PI 3.141592
#define cross(a, b) (conj(a)*b).Y
#define MAN(a, b) norm(a-b)
#define EUC(a, b) abs(a-b)
#define PB push_back
#define REP(i, a, b) for (int i=a; i<b; i++)
#define RREP(i, a, b) for (int i=a; i>=b; i--)
#define heap priority_queue
#define endl '\n'
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned short us;
typedef complex<double> point;
typedef tree<pair<int, int> , null_type, less<pair<int, int>>, rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;

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);

    int t=1;// cin>>t;
    REP(i, 0, t) solve();

    return 0;
}