#include <bits/stdc++.h>
using namespace std;
long long int modulo(long long int a, long long int b) {
  if (b == -1) {
    return 1;
  }
  long long int c = 1e18;
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y) % c;
    }
    y = (y * y) % c;
    b /= 2;
  }
  return x % c;
}
long long int n;
vector<long long int> ans;
void solve(long long int aa, long long int m, long long int b,
           vector<long long int> v) {
  if (b == -1) {
    v.push_back(n);
    long long int a[100] = {0};
    long long int i, j;
    for (i = 0; i < v.size(); i++) {
      a[v[i]] = 1;
      ans.push_back(v[i]);
    }
    for (j = n; j >= 1; j--) {
      if (a[j] == 0) {
        ans.push_back(j);
      }
    }
    return;
  } else {
    long long int i;
    long long int j = n - b - 1;
    long long int va = modulo(2, n - 2);
    for (i = b; i >= 0; i--) {
      va = modulo(2, i);
      if (m > va) {
        m = m - va;
        va = va / 2;
        j++;
      } else {
        v.push_back(j);
        solve(j, m, i - 1, v);
        return;
      }
    }
    v.push_back(n);
    long long int a[100] = {0};
    for (i = 0; i < v.size(); i++) {
      a[v[i]] = 1;
      ans.push_back(v[i]);
    }
    for (j = n; j >= 1; j--) {
      if (a[j] == 0) {
        ans.push_back(j);
      }
    }
    return;
  }
}
int main() {
  long long int m;
  scanf("%lld", &n);
  scanf("%lld", &m);
  if (n == 1) {
    cout << "1\n";
    return 0;
  }
  ans.clear();
  long long int i, j;
  long long int va = modulo(2, n - 2);
  if (m <= va) {
    vector<long long int> v;
    v.push_back(1);
    long long int j = 2;
    for (i = n - 3; i >= 0; i--) {
      va = modulo(2, i);
      if (m > va) {
        m = m - va;
        j++;
      } else {
        v.push_back(j);
        solve(j, m, i - 1, v);
        for (i = 0; i < ans.size(); i++) {
          cout << ans[i] << " ";
        }
        cout << "\n";
        return 0;
      }
    }
    cout << 1 << " " << n << " ";
    ans.push_back(n);
    for (i = n - 1; i >= 2; i--) {
      cout << i << " ";
    }
    cout << "\n";
  } else {
    long long int va = modulo(2, n - 1);
    if (va - m + 1 == (va / 2)) {
      for (i = 2; i <= n; i++) {
        cout << i << " ";
      }
      cout << 1 << " ";
      cout << "\n";
    } else {
      m = va - m + 1;
      vector<long long int> v;
      v.push_back(1);
      long long int j = 2;
      for (i = n - 3; i >= 0; i--) {
        va = modulo(2, i);
        if (m > va) {
          m = m - va;
          j++;
        } else {
          v.push_back(j);
          solve(j, m, i - 1, v);
          for (i = ans.size() - 1; i >= 0; i--) {
            cout << ans[i] << " ";
          }
          cout << "\n";
          return 0;
        }
      }
      cout << 1 << " " << n << " ";
      ans.push_back(n);
      for (i = n - 1; i >= 2; i--) {
        cout << i << " ";
      }
    }
  }
}
