#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; if (m == 0) { cout << 0 << '\n'; return 0; } string ans = ""; while (m) { ans += char('0' + (m % n)); m /= n; } reverse(ans.begin(), ans.end()); cout << ans << '\n'; }