#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int N = (int)(2e6 + 20);
const int L = 1 << 6;
const long long int M = (long long int)(1e9 + 7);
const double E = 1e-7;
int a[N];
int main() {
  ios_base::sync_with_stdio(0);
  long long int n, m;
  cin >> n >> m;
  int tm = m;
  if (n > 3) {
    int f = 0, l = n - 1;
    m--;
    vector<int> v(n - 1);
    for (int i = 0; i < n - 1; ++i) {
      v[i] = m & 1;
      m /= 2;
    }
    for (int i = 0; i < n - 1; ++i) {
      if (v[n - i - 2])
        a[l--] = i + 1;
      else
        a[f++] = i + 1;
    }
    a[f] = n;
    for (int i = 0; i < n; ++i) cout << a[i] << ' ';
    cout << endl;
    return 0;
  }
  m = tm;
  long long int maxV = 0;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) v[i] = i + 1;
  do {
    long long int curV = 0;
    for (int i = 0; i < n; ++i) {
      int minV = v[i];
      for (int j = i; j < n; ++j) {
        minV = min(minV, v[j]);
        curV += minV;
      }
    }
    maxV = max(curV, maxV);
  } while (next_permutation(v.begin(), v.end()));
  for (int i = 0; i < n; ++i) v[i] = i + 1;
  int cnt = 0;
  do {
    long long int curV = 0;
    for (int i = 0; i < n; ++i) {
      int minV = v[i];
      for (int j = i; j < n; ++j) {
        minV = min(minV, v[j]);
        curV += minV;
      }
    }
    if (curV == maxV) {
      ++cnt;
    }
    if (cnt == m && true) {
      for (int i = 0; i < n; ++i) cout << v[i] << ' ';
      return 0;
    }
  } while (next_permutation(v.begin(), v.end()));
  cout << cnt;
  return 0;
}
