#include <iostream>
using namespace std;
int main()
{
int n, r;
cin >> n >> r;
char c[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string ans = "";
while (n)
{
ans = c[n % r] + ans;
n /= r;
}
cout << ans;
return 0;
}