#include<bits/stdc++.h> using namespace std; int n,d; stack<char> s; string sum="0123456789ABCDEF"; int main(){ cin>>n>>d; if(n==0){ cout<<0; return 0; } while(n!=0){ s.push(sum[n%d]); n/=d; } while(!s.empty()){ cout<<s.top(); s.pop(); } return 0; }