#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
vector<int> mod(int a,int b,vector<int>&p)
{
while(true)
{
if (a != 0)
{
int w;
w = a % b;
int q = a / b;
if ( w< 0)
{
w -= b;
q += 1;
}
p.push_back(w);
a = q;
}
else
{
break;
}
}
return p;
}
int main()
{
vector<int>p;
int n; int r;
cin >> n >> r;
mod(n, r, p);
cout << n << "=";
char al[] = { '0','1','2','3','4','5','6','7','8','9','A','B' ,'C' ,'D' ,'E' ,'F' ,'G','H','I','J','K','L','M' };
for (int i =p.size()-1;i>=0;i--)
{
cout << al[p[i]];
//cout << p[i];
}
cout << "(base" << r << ")";
//cout << endl;
//cout << -142% -7 << endl;
//cout << -142/ -7 << endl;
}
06-29
597
05-26
1584
08-08
1025
12-31
453
04-17
1439