#include <bits/stdc++.h>
using namespace std;
long long power(long long a, int b) {
  long long ans = 1LL;
  while (b) {
    if (b & 1) ans = (ans * a);
    a = (a * a);
    b /= 2;
  }
  return ans;
}
int main() {
  int t, m, n, i, j, k, l;
  t = 1;
  while (t--) {
    long long m;
    cin >> n >> m;
    if (n == 2 && m == 2) {
      cout << "2 1\n";
      return 0;
    }
    int a[n + 1];
    memset(a, 0, sizeof(a));
    int st, en;
    st = 1;
    en = n;
    for (i = 1; i <= n; i++) {
      long long x = power(2, n - i - 1);
      if (m > x) {
        m -= x;
        a[en] = i;
        en--;
      } else {
        a[st] = i;
        st++;
      }
    }
    for (i = 1; i <= n; i++) cout << a[i] << " ";
  }
  return 0;
}
