#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
vector<string> litery = {"", "", "ABC", "DEF", "GHI", "JKL", "MNO", "PQRS", "TUV", "WXYZ"};
int main() {
string numer;
long long K;
cin >> numer >> K;
vector<string> grupy_liter;
for (char cyfra : numer) {
grupy_liter.push_back(litery[cyfra - '0']);
}
string wynik;
int n = grupy_liter.size();
string aktualnaKombinacja(n, ' ');
function<void(int, long long&)> backtrack = [&](int index, long long &licznik) {
if (index == n) {
licznik++;
if (licznik == K) {
wynik = aktualnaKombinacja;
}
return;
}
for (char litera : grupy_liter[index]) {
aktualnaKombinacja[index] = litera;
backtrack(index + 1, licznik);
if (!wynik.empty()) return;
}
};
long long licznik = 0;
backtrack(0, licznik);
cout << wynik << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZlY3RvcjxzdHJpbmc+IGxpdGVyeSA9IHsiIiwgIiIsICJBQkMiLCAiREVGIiwgIkdISSIsICJKS0wiLCAiTU5PIiwgIlBRUlMiLCAiVFVWIiwgIldYWVoifTsKCmludCBtYWluKCkgewogICAgc3RyaW5nIG51bWVyOwogICAgbG9uZyBsb25nIEs7CiAgICBjaW4gPj4gbnVtZXIgPj4gSzsKCiAgICB2ZWN0b3I8c3RyaW5nPiBncnVweV9saXRlcjsKICAgIGZvciAoY2hhciBjeWZyYSA6IG51bWVyKSB7CiAgICAgICAgZ3J1cHlfbGl0ZXIucHVzaF9iYWNrKGxpdGVyeVtjeWZyYSAtICcwJ10pOwogICAgfQoKICAgIHN0cmluZyB3eW5pazsKICAgIGludCBuID0gZ3J1cHlfbGl0ZXIuc2l6ZSgpOwogICAgc3RyaW5nIGFrdHVhbG5hS29tYmluYWNqYShuLCAnICcpOwoKICAgIGZ1bmN0aW9uPHZvaWQoaW50LCBsb25nIGxvbmcmKT4gYmFja3RyYWNrID0gWyZdKGludCBpbmRleCwgbG9uZyBsb25nICZsaWN6bmlrKSB7CiAgICAgICAgaWYgKGluZGV4ID09IG4pIHsKICAgICAgICAgICAgbGljem5paysrOwogICAgICAgICAgICBpZiAobGljem5payA9PSBLKSB7CiAgICAgICAgICAgICAgICB3eW5payA9IGFrdHVhbG5hS29tYmluYWNqYTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm47CiAgICAgICAgfQoKICAgICAgICBmb3IgKGNoYXIgbGl0ZXJhIDogZ3J1cHlfbGl0ZXJbaW5kZXhdKSB7CiAgICAgICAgICAgIGFrdHVhbG5hS29tYmluYWNqYVtpbmRleF0gPSBsaXRlcmE7CiAgICAgICAgICAgIGJhY2t0cmFjayhpbmRleCArIDEsIGxpY3puaWspOwoKICAgICAgICAgICAgaWYgKCF3eW5pay5lbXB0eSgpKSByZXR1cm47CiAgICAgICAgfQogICAgfTsKCiAgICBsb25nIGxvbmcgbGljem5payA9IDA7CiAgICBiYWNrdHJhY2soMCwgbGljem5payk7CiAgICBjb3V0IDw8IHd5bmlrIDw8IGVuZGw7CiAgICByZXR1cm4gMDsKfQo=