#include <iostream>
#include <algorithm>

int main()
{
    int n, m, code_count = 0;
    std::cin >> n >> m;
    std::string code(n, '0');
    code[n - 1] = '1';
    for (int i = 1; i < m && code_count < m; ++i)
    {
        while (next_permutation(code.end() - i, code.end()) && code_count < m)
            ++code_count;
        code[code.size() - i - 1] = '1';
        ++code_count;
    }
    std::cout << code;
    return 0;
}
