#include <iostream>
#include <algorithm>
using namespace std;
main()
{

            int n;
            int k;
            cin>>n;
            cin>>k;
            int niz[n];
            for (int i = 0; i < n; i++)
            {
                cin>>niz[i];
            }
            sort(niz, niz+n);
            int piz[n];
            int br = 0; int pk = 1; int pom = niz[0];
            for (int i = 1; i<n; i++)
            {
                if (i == n - 1)
                {
                    if (niz[i] == pom)
                    {
                        pk++;
                        if (pk >= k)
                        {
                            pk = 1;
                            piz[br] = pom;
                            br++;
                        }
                    }
                }
                else
                {
                    if (niz[i] == pom)
                    {
                        pk++;
                    }
                    else
                    {
                        if (pk >= k)
                        {
                            pk = 1;
                            piz[br] = pom;
                            br++;
                        }
                        else
                        {
                            pk = 1;
                        }
                    }
                    pom = niz[i];
                }
            }
            cout<<br<<endl;
            for (int i = 0; i < br; i++)
            {
               cout<<piz[i];
            }

        }