#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x;
stack<int> s;
cin>>n>>x;
if(n==0) cout<<0<<endl;
while(n){
s.push(n%x);
n/=x;
}
while(s.size()){
if(s.top()>10){
cout<<(char)('A'+(int)s.top()-10);
s.pop();
continue;
}
cout<<s.top();
s.pop();
}
}