#include <bits/stdc++.h>   using namespace std;   int v[100];   bool cmp(int a, int b) { return a > b; }   int highest(int n) {     int i = 1, fact = 0;     while (2 * i <= n) {       i *= 2;       fact++;     }     return fact;   }   void permute(int left, int right, int pos, int last) {     if (!pos || (!last && pos == 1)) return;     int t = highest(pos);     pos -= (1 << t);     if (!last) {       left = right - t - 1;       swap(v[left + 1], v[right]);       sort(v + left + 2, v + right, cmp);       permute(left, right, pos, t);       return;     }     swap(v[left], v[right]);     --right;     if (last - t != 1) {       ++left;       sort(v + left, v + right + 1);       permute(left, right, pos + (1 << t), 0);       return;     }     permute(left, right, pos, t);   }   int main() {     int n, m, num = 1, piv = 0, pos, t;     cin >> n >> m;     for (int i = 0; i < n; ++i) v[i] = i + 1;     permute(0, n - 1, m, 0);     for (int i = 0; i < n; ++i) cout << v[i] <<    ;     return 0;   }   