#include <bits/stdc++.h>
int n;
long long m;
int a[55];
bool check[55];
int main() {
  scanf("%d %I64d", &n, &m);
  int left = n;
  for (int i = 1; i <= n && left; i++) {
    for (int j = 1; j <= n && left; j++) {
      if (check[j]) continue;
      if (left == 1) {
        a[i] = j;
        check[j] = true;
        left = 0;
        break;
      }
      if (m > (long long)1 << (left - 2)) {
        m -= (long long)1 << (left - 2);
        a[i + left - 1] = j;
        check[j] = true;
        left--;
      } else {
        a[i] = j;
        check[j] = true;
        left--;
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", a[i]);
  return 0;
}
