#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
const char nc[20] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J' };
string ans;
int n;
int r;
cin >> n >> r;
int temp = n, temp1 = 1;
cout << n << "=";
while (temp != 0) {
temp1 = temp % r;
temp = temp / r;
if (temp1 < 0 ){
temp++;
temp1 -= r;
}
ans.push_back(nc[temp1]);
}
for (int i = ans.length() - 1; i >= 0; i--) {
cout << ans[i];
}
cout << "(base" << r << ")";
return 0;
}