#include <bits/stdc++.h>

using namespace std;


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string s, t;

    cin >> s >> t;

    int n = s.size(), m = t.size();

    vector<vector<int>> brP;
    vector<int> tmp(m);

    for(int i = n-1; i >= 0; --i){
        for(int j = 0; j < m; ++j){
            if(s[i] == t[j]) ++tmp[j];
        }
        if(s[i] == t[0]) brP.push_back(tmp);
    }

    int minCnt = INT_MAX, tmpCnt = 0, ind = brP.size()-1, cnt = 0, chInd = 0;

    for(int i = 0; i < n; ++i){
        if(s[i] == t[0]){
            int tmpMin = brP[ind][0], tmpCh = 0;
            for(int j = 1; j < m; ++j){
                if(brP[ind][j] < tmpMin) { tmpMin = brP[ind][j]; tmpCh = j; }
            }
            if(tmpMin+tmpCnt < minCnt) { minCnt = tmpMin+tmpCnt; cnt = tmpCnt; chInd = tmpCh; }
            ++tmpCnt;
            --ind;
        }
    }

    char ch = t[chInd];

    for(int i = 0; i < n; ++i){
        if(s[i] == s[0] && cnt != 0){
            s[i] = '*';
            while(i < n && s[i] != t[0]) ++i;
            --cnt;
        }
        else if(s[i] == ch && cnt == 0) s[i] = '*';
    }

    cout << minCnt << '\n' << s << '\n';
    return 0;
}