#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,d;
string s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",res="";
cin>>a>>b;
while(a>0){
d = a%b;
res = s[d]+res;
a/=b;
}
cout<<res;
return 0;
}
data = int(input())
base = int(input())
digits = "0123456789ABCDEFGHJKLMNOPQRSTUVWXYZ"
result = ''
while data>0:
remainder = data % base
result = digits[remainder]+result
data//=base
print(result)