#include <bits/stdc++.h>
using namespace std;
int n, a[55];
long long m, p2[55];
int main() {
  cin >> n >> m;
  p2[0] = 1;
  for (int i = 1; i <= 50; ++i) p2[i] = p2[i - 1] * 2;
  int l = 1, r = n, cnt = n - 1;
  for (int num = 1; num <= n; ++num) {
    --cnt;
    if (cnt >= 0 && m > p2[cnt]) {
      a[r--] = num;
      m -= p2[cnt];
    } else {
      a[l++] = num;
    }
  }
  for (int i = 1; i <= n; ++i) cout << a[i] << ' ';
  cout << endl;
}
