#ifdef LOCAL #include #else #pragma GCC optimize("O3") // #pragma target("arch=skylake-avx512") #include #define debug(...) ((void)0) #endif using namespace std; using ll = long long; using ld = long double; void solve(int) { string N; cin >> N; vector num; for (int i = 0; i < (int)N.size(); i++) { num.push_back(N[i] - '0' + 1); } reverse(num.begin(), num.end()); debug(num); ll K; cin >> K; K -= 1; vector ans; for (auto&& x : num) { ans.push_back(K % x); K /= x; if (K == 0) break; } reverse(ans.begin(), ans.end()); for (auto&& x : ans) { cout << x; } cout << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t = 1; // cin >> t; for (int i = 1; i <= t; i++) { solve(i); } #ifdef LOCAL postprocess(); #endif }