#include <bits/stdc++.h>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> ans;

    if (M == 0) {
        ans.push_back(0);
    }

    while (M) {
        ans.push_back(M % N);
        M /= N;
    }

    reverse(ans.begin(), ans.end());

    for (int d : ans) {
        cout << d;
    }
    cout << endl;

    return 0;
}