#include <bits/stdc++.h>
using namespace std;
int value(vector<int> v) {
  int val = 0, i, j, n = v.size();
  for (i = 0; i < n; i++) {
    for (j = i; j < n; j++)
      val += *min_element(v.begin() + i, v.begin() + j + 1);
  }
  return val;
}
int main() {
  ios_base::sync_with_stdio(0);
  ;
  cin.tie(0);
  cout.tie(0);
  int n, i, x;
  long long int m;
  cin >> n >> m;
  m--;
  int a[n + 1];
  int l = 0, r = n - 1;
  for (i = 1; i < n; i++) {
    if (m >= (1LL << (n - i - 1))) {
      m -= (1LL << (n - i - 1));
      a[r--] = i;
    } else
      a[l++] = i;
  }
  a[l] = n;
  for (i = 0; i < n; i++) cout << a[i] << " ";
  return 0;
}
