#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        string s;
        for(;;){
            string tmp;
            getline(cin, tmp);
            if(tmp == "")
                break;
            s += tmp;
        }
        int n = s.size();
        if(n == 0)
            return 0;

        string key;
        getline(cin, key);
        int m = key.size();
        vector<bool> isKey(256, false);
        for(int i=0; i<m; ++i)
            isKey[key[i]] = true;

        vector<int> last(256, -1);
        set<int> pos;
        int num;
        int head;
        int len = INT_MAX;
        for(int i=0; i<n; ++i){
            if(isKey[s[i]]){
                if(last[s[i]] != -1)
                    pos.erase(pos.find(last[s[i]]));
                last[s[i]] = i;
                pos.insert(i);

                if(pos.size() == m){
                    int len2 = i - *(pos.begin()) + 1;
                    if(len2 < len){
                        len = len2;
                        num = 1;
                        head = *(pos.begin());
                    }else if(len2 == len){
                        ++ num;
                    }
                }
            }
        }

        if(len == INT_MAX){
            cout << '0' << endl;
        }else{
            cout << num << endl << endl;
            while(len > 72){
                cout << s.substr(head, 72) << endl;
                head += 72;
                len -= 72;
            }
            cout << s.substr(head, len) << endl;
        }
        cout << endl;

        getline(cin, s);
    }
}