#include <bits/stdc++.h>
using namespace std;
int n;
long long m;
int main() {
  scanf("%d %lld", &n, &m);
  long long size(1LL << n >> 1);
  int val = 1;
  bool add = true;
  set<int> got;
  for (int i = 1; i <= n; i++) got.insert(i);
  for (int pos = 1; pos <= n; pos++) {
    size /= 2;
    bool out = false;
    for (long long x = size; x > 0; x /= 2) {
      if (m <= x) {
        printf("%d ", val);
        got.erase(val);
        out = true;
      }
      if (!out) {
        m -= x;
        size /= 2;
      }
      if (add) {
        val++;
        if (val == n) add = false;
      } else {
        val--;
        if (val == 1) add = true;
      }
      if (out) break;
    }
  }
  vector<int> v;
  for (set<int>::iterator it = got.begin(); it != got.end(); it++)
    v.push_back(*it);
  reverse((v).begin(), (v).end());
  for (int i = 0; i < ((int)(v).size()); i++) printf("%d ", v[i]);
  printf("\n");
  return 0;
}
