/*
ZADATAK: proizvod
JEZIK: C++
*/

#include <fstream>
#include <vector>
#include <cctype>

using namespace std;

// Konstanti
const int MAX_N = 100000;
const int MAX_M = 8;

const int exp10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 };

// Globalni varijanti
int N, M;
char cifra[MAX_N];

vector<bool> kuda(MAX_N);

// Funkcije
inline int vred(char c) { return c-'0'; }

bool manji(bool k, size_t n) {
     static int s0, s1;
     static short e0, e1;
     static bool p, m;
     
     if (k) {
            s1++;
            e1 = vred(cifra[n]);
     }
     else {
            s0++;
            e0 = vred(cifra[n]);
     }
     
     if (s0==s1) {
        if (p) return m;
        else {
             if (e0==e1) return false;
             else {
                  p = true;
                  return m = (e0>e1);
             }
        }
     }
     else return s0<s1 ? false : true;
}

int main()
{
    char ch;
    bool next;
    
    // Input
    ifstream in("proizvod.in");
    
    in>>N>>M;
    do in.get(ch); while (isspace(ch)); in.putback(ch);
    for (size_t i=0; i<N; i++) in>>cifra[i];
    
    in.close();
    
    // Rad
    sort(cifra, cifra+N, greater<char>());
    next = manji(false, 0);
    kuda[0] = false;
    for (size_t i=1; i<N; i++) {
        kuda[i] = next;
        next = manji(next, i);
    }
    
    long long int t0 = 0, t1 = 0;
    int j = N;
    for (int i=0; i<M; i++) {
        j--;
        while (j>=0 && kuda[j]) j--;
        if (j>=0) t0 += vred(cifra[j]) * exp10[i];
    }
    j = N;
    for (int i=0; i<M; i++) {
        j--;
        while (j>=0 && !kuda[j]) j--;
        if (j>=0) t1 += vred(cifra[j]) * exp10[i];
    }
    
    // Output
    ofstream out("proizvod.out");
    
    char output[MAX_M+1];
    sprintf(output, "%08d", (t0*t1) % exp10[M] );
    out << output+MAX_M-M << endl;
    
    out.flush(); out.close();

    return 0;
}
