#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, M;
    cin >> N >> M;
    string ans;
    while(M){
        ans += M % N + '0';
        M /= N;
    }
    if(ans.empty())ans += '0';
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
}