#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); string s; ll k; cin >> s >> k; k--; ll mul = 1; const int n = s.size(); string t(n, '0'); for(int i = 0; i < n; i++){ mul *= s[i] - '0' + 1; } for(int i = 0; i < n; i++){ mul /= s[i] - '0' + 1; int d = k / mul; t[i] += d; k -= mul * d; } cout << stoll(t) << '\n'; }