#include <bits/stdc++.h>
#define int long long
using namespace std;
int cha[15];
int lis[15];
int selection[10005],k = 0;
int n;
bool check(){
    bool kq = false;
    for (int i = 0 ; i <= 9 ; i++){
        if(cha[i]!=0)return false;
    }
    return true;
}
vector<int> kq;
bool timthay = false;
void dequy(int vitri , int now , vector<int> v){
    if(timthay)return;
    if(now == n && check()){
        kq = v;
        timthay = true;
        return;
    }
    if(vitri == k || now > n)return;
    // chon selection hientai
    if (n % (now * selection[vitri]) == 0){
    string s1=to_string(selection[vitri]);
    bool khathi = true;
    for (char x : s1){
        cha[x-'0']--;
        if(cha[x-'0']<0)khathi=false;
    }
    if(khathi){
        v.push_back(selection[vitri]);
        dequy(vitri,now*selection[vitri],v);
        v.pop_back();
    }
    //khoi phuc
    for (char x : s1){
        cha[x-'0']++;
    }
    }

    //ko chon
    dequy(vitri+1,now,v);
}
vector<int> temp;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    string s;
    cin>>s;
    for (char x : s){
        cha[x-'0']++;
    }
    set<int> liset;
    for (int i = 1 ; i*i <= n ; i++){
        if(n%i==0){
            for (int j = 0 ; j <= 9 ; j++)lis[j]=0;
            string s1 = to_string(n/i);
            for (char x : s1)lis[x-'0']++;
            bool check1 =true;
            for (int j = 0 ; j <= 9 ; j++){
                if(lis[j]>cha[j]){
                    check1=false;
                    break;
                }
            }
            for (int j = 0 ; j <= 9 ; j++)lis[j]=0;
            string s2 = to_string(i);
            for (char x : s2)lis[x-'0']++;
            bool check2 =true;
            for (int j = 0 ; j <= 9 ; j++){
                if(lis[j]>cha[j]){
                    check2=false;
                    break;
                }
            }
            //cout<<i<<" "<<n/i<<"\n";
            if(check1)liset.insert(n/i);
            if(check2)liset.insert(i);
        }
    }
    for (auto x : liset)selection[k++]=x;
    dequy(0,1,temp);
    cout<<kq.size()<<" ";
    for (auto x : kq)cout<<x<<" ";
    return 0;
}