//因为数值转换的最后的结果是逆序排列,故可以用堆来实现
//这里用静态的顺序栈来实现数制的转换
include<iostream>
#include<stdio.h>
using namespace std;
#define max_stacksize 200
typedef int ElemType;
typedef struct SqStack{
ElemType Stack_arry[max_stacksize];
int top;
}SqStack;
void init_stack(SqStack &s){ //初始化协议栈
s.top=-1;
}
int push(SqStack &s,int x){ //进栈操作
if(s.top>=max_stacksize-1){
printf("栈满!");
}
else{
s.Stack_arry[++s.top]=x;
}
return 0;
}
int pop(SqStack &s,int &x){ //退栈操作
if(s.top==-1){
printf("栈空!");
}
else{
x=s.Stack_arry[s.top--];
}
return x;
}
void conversion(int n,int d){ //将n进制的数转化为d进制的数
SqStack s;
init_stack(s);
int b,e;
while(n!=0){
b=n%d; //求余
n=n/d; //求商
push(s,b);
}
while(s.top!=-1){
pop(s,e);
printf("%d",e);
}
}
int main(){
int N,D;
cin>>N>>D;
conversion(N,D);
return 0;
}