#include<ctime>
#include<cstdio>
#include<cctype>
#include<cstring>
#define ll long long
using namespace std;
const ll N=3e6+7;
ll read() {
	char c;
	ll x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while (isdigit(c)){
		x=x*10+(c-48)*f;
		c=getchar();
	}
	return x;
}
ll n,k,t,sum,f[5][N];
ll c[N];
void add(ll x,ll k){
	for(;x<=n*3;x+=x&-x)
		c[x]+=k;
}
ll ask(ll x){
	ll res=0;
	for(;x;x-=x&-x)
		res+=c[x];
	return res;
}
int main() {
	#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	k=read();
	f[0][0]=1;
	for(ll i=1;i<=3;++i){
		memset(c,0,sizeof(c));
		for(ll j=0;j<=n*(i-1);++j){
			add(j+1,f[i-1][j]);
			add(j+n+1,-f[i-1][j]);
		}
		for(ll j=0;j<=n*i;++j)
			f[i][j]=ask(j);
	}
	for(ll i=3;i<=n*3;++i){
		if(t+f[3][i]<k){
			t+=f[3][i];
			continue;
		}
		sum=i;
		k-=t;
		t=0;
		break;
	}
	for(ll i=n*2;i>1;--i){
		if(i>=sum)
			continue;
		if(t+f[2][i]<k){
			t+=f[2][i];
			continue;
		}
		printf("%lld ",sum-i);
		sum=i;
		k-=t;
		t=0;
		break;
	}
	for(ll i=n;i;--i){
		if(i>=sum)
			continue;
		if(t+f[1][i]<k){
			t+=f[1][i];
			continue;
		}
		printf("%lld %lld",sum-i,i);
		break;
	}
	//--------
	clock_t t2=clock();
	fprintf(stderr,"time:%0.3lfs",1.0*(t2-t1)/CLOCKS_PER_SEC);
	return 0;
}
#include <bits/stdc++.h>
int n;
long long k, dp[4][3000005];
int main() {
  std::cin >> n >> k; 
  for (int i = 1; i <= n; ++i) dp[1][i] = 1;
  for (int i = 2; i <= 3; ++i) {
    for (int j = 1; j <= i * n; ++j) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
    for (int j = i * n; j > n; --j) dp[i][j] -= dp[i][j - n];
  }
  for (int i = 1; i <= 3 * n; ++i) 
    if (k <= dp[3][i]) {
      for (int j = 1; j <= i; ++j) {
        if (k <= dp[2][i - j]) {
          for (int x = 1; x <= i - j; ++x) {
            if (k <= dp[1][i - j - x]) {
              std::cout << j << " " << x << " " << i - j - x;
              return 0;
            } else k -= dp[1][i - j - x];
          }
        } else k -= dp[2][i - j];
      }
    } else k -= dp[3][i];
  return 0;
}