#include<bits/stdc++.h> using namespace std; stack <int> s; stack<char> s1; int main(){ int n,m; cin>>n>>m; while (n!=0){ s.push(n%m); n=n/m; } while(!s.empty()){ cout<<s.top(); s.pop(); } return 0; }