#include <bits/stdc++.h>

using namespace std;

bool isIn(char a, string s) {
  for(int i = 0 ; i < s.length() ; i++) {
    if(a == s[i]) return true;
  }
  return false;
}

int main() {

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

    string a, b;
    cin>>a;
    cin>>b;

    char mi = 'A';
    int Counter = -1;
    unordered_map<char, int> p;
    string Postojeci = "";

    while(!isIn(mi, b))
    {
      for(int i = 0 ; i < a.length() ; i++) {
        p[a[i]]++;
      }
      for(auto& i : p) {
        if(mi == 'A') {
          mi = i.first;
          Counter = i.second;
        }
        else if(i.second < Counter) {
          mi = i.first;
          Counter = i.second;
        }
      }
      Postojeci += mi;
    }

    cout<<Counter<<"\n";

    for(int i = 0 ; i < a.length() ; i++) {
      if(a[i] == mi) a[i] = '*';
    }

    cout<<a<<"\n";

  return 0;
}