#include <iostream>
#define forn(i, n) for (int i = 0; i < n; i++)
using namespace std;
const int oo = 2e5 + 7;
int dp[oo][10], nextd[oo][10];
string t, s;
int gdp(int x, int y) {
    if (dp[x][y] != -1) return dp[x][y];
    if (t[x] == s[y] && y == 0) dp[x][y] = 1 + gdp(x-1, y), nextd[x][y] = 0;
    else if (t[x] == s[y]) {
        int d1 = gdp(x-1, y-1);
        int d2 = 1 + gdp(x-1, y);
        dp[x][y] = min(d1, d2);
        nextd[x][y] = d1 <= d2 ? 1 : 2;
    }
    else dp[x][y] = gdp(x-1, y), nextd[x][y] = 3;
    return dp[x][y];
}
int n, m;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> t >> s;
    n = t.size(), m = s.size();
    forn(i, n) forn(j, m) dp[i][j] = nextd[i][j] = -1;
    forn(j, m) dp[0][j] = j == 0 && t[0] == s[0];
    forn(j, m) nextd[0][j] = dp[0][j] ? 0 : 1;
    int x = n-1, y = m-1;
    cout << gdp(n-1, m-1) << endl;
    while (x >= 0) {
        int nextv = nextd[x][y];
        // if (nextv == -1) throw 1;
        if (nextv == 2 || nextv == 0) t[x] = '*';
        if (nextv == 1) y--;
        x--;
    }
    cout << t << endl;
    #ifdef CHUNGUS
    system("pause");
    #endif
}