#include<bits/stdc++.h>
using namespace std;
int main(){
long long x,m;
cin >> x >> m;
string temp = "";
while(x > 0){
long long a;
a = x;
a = a % m; //取余数
long long b = a;
string ans = to_string(a); //转换成string类型
temp = ans + temp;
x = x / 2; //取出下次循环的x
}
cout << temp << endl;
return 0;
}