#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SIZE = 1e6 + 10;
int n;
long long m;
vector<int> vec;
void printperm() {
  for (int i = 0; i < (n); ++i) {
    if (i > 0) printf(" ");
    printf("%d", vec[i]);
  }
}
void go(int lef, int rig, int num, long long m) {
  if (n - num == 0) {
    vec[lef] = num;
    return;
  }
  long long pp2 = 1L;
  if (n - num - 1 > 0) pp2 <<= ((long long)n - num - 1);
  if (m <= pp2) {
    vec[lef] = num;
    go(lef + 1, rig, num + 1, m);
  } else {
    vec[rig] = num;
    go(lef, rig - 1, num + 1, m - pp2);
  }
}
int main() {
  if (0) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  scanf("%d %I64d", &n, &m);
  vec.resize(n);
  go(0, n - 1, 1, m);
  printperm();
  printf("\n");
  return 0;
}
