#include <iostream>
#include <stack>
using namespace std;
int main()
{
unsigned long long n,m;
cin >> n >> m;
stack<unsigned long long> s;
while (n)
{
s.push(n % m);
n /= m;
}
while (!s.empty())
{
cout << s.top();
s.pop();
}
cout << endl;
return 0;
}