#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long a[50];
int main() {
  cin >> N >> M;
  if (N == 1) {
    cout << 1 << endl;
    return 0;
  } else if (N == 2 && M == 1) {
    cout << "1 2" << endl;
    return 0;
  } else if (N == 2 && M == 2) {
    cout << "2 1" << endl;
    return 0;
  }
  M--;
  for (long long i = 1, l = 0, r = N - 1, j = 1ll << (N - 1); i <= N;
       i++, j /= 2) {
    if (M >= j / 2) {
      M -= j / 2;
      a[r] = i;
      r--;
    } else {
      a[l++] = i;
    }
  }
  for (int i = 0; i < N; i++) cout << a[i] << ' ';
  cout << endl;
  return 0;
}
