#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
map<int, int> tagCnt;
class Solution {
  long long n, m;
  vector<int> P(int n, long long m) {
    if (n == 1) return {0};
    vector<int> ret;
    if (m < (1ll << n - 2)) {
      ret.push_back(0);
      auto A = P(n - 1, m);
      for (int i = 0; i < n - 1; ++i) ret.push_back(A[i] + 1);
    } else {
      auto A = P(n - 1, m - (1ll << n - 2));
      for (int i = 0; i < n - 1; ++i) ret.push_back(A[i] + 1);
      ret.push_back(0);
    }
    return ret;
  }

 public:
  void run() {
    cin >> n >> m;
    vector<int> A = P(n, m - 1);
    for (int i = 0; i < n; ++i) cout << A[i] + 1 << " \n"[i == n - 1];
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Solution().run();
}
