#include <bits/stdc++.h>
using namespace std;
template <typename t1, typename t2>
ostream& operator<<(ostream& os, const pair<t1, t2>& a) {
  os << a.first << ' ' << a.second;
  return os;
}
template <typename typ>
void vout(vector<typ>& v) {
  for (int vint = 0; vint < (int)(v).size(); vint++) {
    cout << (v)[vint];
    if (vint == (int)(v).size() - 1)
      cout << '\n';
    else
      cout << ' ';
  }
}
template <typename typ>
void arrout(typ* arr, int l) {
  for (int i = 0; i < l; i++) {
    cout << arr[i];
    if (i < l - 1)
      cout << ' ';
    else
      cout << '\n';
  }
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
int main() {
  std::ios_base::sync_with_stdio(false);
  int n;
  long long m;
  cin >> n >> m;
  int ans[n + 1];
  int left = 1, right = n;
  long long p = (1LL << (n - 2));
  for (int i = 1; i <= n; i++) {
    if (m > p) {
      ans[right--] = i;
      m -= p;
    } else {
      ans[left++] = i;
    }
    p /= 2;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i];
    if (i < n) {
      cout << ' ';
    } else {
      cout << endl;
    }
  }
}
