#include <bits/stdc++.h>
using namespace std;
void cleverSolve() {
  int n;
  cin >> n;
  long long m;
  cin >> m;
  m--;
  vector<int> v(n);
  int l = 0, r = n - 1;
  for (int i = n - 2, j = 1; i >= 0; i--, j++) {
    if (m & (1ll << i)) {
      v[r--] = j;
    } else {
      v[l++] = j;
    }
  }
  v[l++] = n;
  for (int i = 0; i < n; i++) {
    cout << v[i] << " ";
  }
}
void solve() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    v.push_back(i);
  }
  vector<pair<int, vector<int> > > res;
  do {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int minval = v[i];
      for (int j = i; j < n; j++) {
        minval = min(minval, v[j]);
        sum += minval;
      }
    }
    res.push_back(make_pair(sum, v));
  } while (next_permutation(v.begin(), v.end()));
  sort(res.begin(), res.end());
  reverse(res.begin(), res.end());
  while (res.back().first < res[0].first) {
    res.pop_back();
  }
  reverse(res.begin(), res.end());
  for (int i = 0; i < n; i++) {
    cout << res[m - 1].second[i] << " ";
  }
}
int main() {
  if (0) freopen("input.txt", "rt", stdin);
  if (0) freopen("output.txt", "wt", stdout);
  cleverSolve();
}
