#include <iostream> using namespace std; int main() { int n, p; cin >> n >> p; if (n == 0) { cout << 0; return 0; } string ans = ""; int sgn = 1; if (n < 0) sgn = -1; n = abs(n); while (n > 0) { ans += ('0' + n % p); n /= p; } if (sgn == -1) { ans += '-'; } for (int i = 0; i < ans.size(); i++) { cout << ans[ans.size() - 1 - i]; } return 0;}
using namespace std;
int main() { int n, p; cin >> n >> p; if (n == 0) { cout << 0; return 0; } string ans = ""; int sgn = 1; if (n < 0) sgn = -1; n = abs(n); while (n > 0) { ans += ('0' + n % p); n /= p; } if (sgn == -1) { ans += '-'; } for (int i = 0; i < ans.size(); i++) { cout << ans[ans.size() - 1 - i]; } return 0;}