#include <bits/stdc++.h>
using namespace std;
long long gcd(long long X, long long Y) { return (Y ? gcd(Y, X % Y) : X); }
long long get_sum(long long N) { return N * (N + 1) / 2; }
int a[501];
long long h[1000];
int main() {
  long long n, m, i, j, k = 1, g;
  cin >> n >> m;
  g = m;
  long long x = 1, y = n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  if (n == 2) {
    if (m == 1)
      cout << "1 2";
    else
      cout << "2 1";
    return 0;
  }
  h[0] = 1;
  for (i = 1; i <= n; i++) {
    h[i] = h[i - 1] * 2;
  }
  for (i = n - 2; i >= 0; i--) {
    if (h[i] >= m && m != 0) {
      a[x++] = k;
    } else {
      a[y--] = k;
    }
    if (h != 0)
      m = m % h[i];
    else
      m = 0;
    k++;
  }
  if (g % 2 == 0) {
    for (i = y; i >= x; i--) {
      a[i] = k;
      k++;
    }
  } else {
    for (i = x; i <= y; i++) {
      a[i] = k;
      k++;
    }
  }
  for (i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
