#include using namespace std; using str=string; str to_s(int n,int b){ str s; for(;n>0;n/=b){ s=char(n%b)+s; } return s; } int main(){cin.tie(0);ios::sync_with_stdio(false); int B;cin>>B; str D;cin>>D; for(int i=0;i=0;--i){ if(D[i]>=B){ D[i]-=B; if(i){ ++D[i-1]; }else{ D=char(1)+D; } } } str r; int x=0; bool b=false; for(int i=0;i