#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long pw[60];
int ans[60];
int f = 0, e;
void make(int sz, long long tmp, deque<int> &val);
int main() {
  cin >> n >> k;
  e = n - 1;
  pw[0] = 1;
  pw[1] = 1;
  pw[2] = 2;
  pw[3] = 4;
  for (int i = 4; i <= n; i++) {
    pw[i] = pw[i - 1] * 2;
  }
  deque<int> val;
  for (int i = 0; i < n; i++) val.push_back(i + 1);
  make(n, k, val);
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
void make(int sz, long long tmp, deque<int> &val) {
  if (sz == 0) return;
  if (val.size() == 1) {
    ans[f++] = val[0];
    return;
  }
  if (tmp <= pw[sz - 1]) {
    ans[f++] = val[0];
    val.pop_front();
    make(sz - 1, tmp, val);
    return;
  }
  int f1 = val.front();
  val.pop_front();
  ans[e--] = f1;
  tmp -= pw[sz - 1];
  make(sz - 1, tmp, val);
}
