#include <iostream>
using namespace std;
int main(){
    string str;
    string podstr;
    cin>>str;
    cin>>podstr;
    int minimum=200000;
    int indeks;
    int j=0;
    for(int i=0;i<str.length();i++){
        if(str[i]==podstr[j]){
            indeks=i;
            m=1;
            while(str[i+1]==str[i]){
                m++;
                i++;
            }
            if(m<minimum){
                minimum=m;
                minindeks=indeks;
            }
            j++;
        }
    }
    for(int i=0;i<minimum;i++){
        str[minindeks+i]=*;
    }
    cout<<minimum<<endl;
    cout<<str<<endl;
    return 0;
}