#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define int long long
#define reset(x) memset(x,0,sizeof(x))
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define all(a) a.begin(),a.end()
#define PI 3.1415926535897932384626433832795
#define INF 1000000000
#define MOD 1000000007
#define MOD2 1000000009
#define EPS 1e-6 
#define pb push_back
#define fi first
#define se second
#define mp make_pair
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};


signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
    vector<pii> total; // tong, so luong
    int n, k; cin >> n >> k;
    int dp[4][3000005] = {0};
    dp[0][0] = 1;
    for (int i = 0; i < 3; i++)
    {
    	for (int j = 0; j <= i * n; j++)
    	{
    		dp[i + 1][j + 1] += dp[i][j];
    		dp[i + 1][j + n + 1] -= dp[i][j];
    	}
    	for (int j = 1; j <= (i + 1) * n; j++)
    	{
    		dp[i + 1][j] += dp[i + 1][j - 1];
    	}
    }
    int x;
	for(int i=3;i<=3*n;i++){
	if(k<=dp[3][i]){x=i;break;}
	else{k-=dp[3][i];}
	}
	for(int i=1;i<=n;i++){
	int jmi=max(1LL,x-i-n);
	int jma=min(n,x-i-1);
	if(jmi>jma){continue;}
	if(k>(jma-jmi+1)){k-=(jma-jmi+1);continue;}
	int y=jmi+k-1;
	int z=x-i-y;
	cout << i << ' ' << y << ' ' << z << '\n';
	return 0;
	}
}

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define all(v) v.begin(),v.end()

int main() {
    ll N,K;cin>>N>>K;

vector<ll> sum(3*N+1,0);
for(ll i=3;i<=3*N;i++) {
    sum[i]=(i-1)*(i-2)/2;
    if(i-3>=N) {
        ll k=i-3-N;
        sum[i]-=((k+2)*(k+1)/2)*3;
    }
    if(i-3>=2*N) {
        ll k=i-3-2*N;
        sum[i]+=((k+2)*(k+1)/2)*3;
    }
}

vector<ll> rsum(3*N+1,0);
for(ll i=3;i<=3*N;i++) {
    rsum[i]=rsum[i-1]+sum[i];
}

ll s=3;
ll g=3*N;

while(s<g) {
    ll k=(s+g+1)/2;
    if(rsum[k-1]<K) {
        s=k;
    }
    else {
        g=k-1;
    }
}

K-=rsum[s-1];

vector<ll> kirei(s-1,0);
ll s2=max(1LL,s-2*(N));

for(ll i=s2;i<=min(N,s-2);i++) {
    ll k=s-i-2;
    kirei[i]=k+1;
    if(k>=N) {
        ll t=k-N;
        kirei[i]-=(t+1)*2;
    }
    if(k>=2*N) {
        ll t=k-2*N;
        kirei[i]+=t+1;
    }
}

vector<ll> rkirei(s-1,0);

for(ll i=s2;i<=min(N,s-2);i++) {
    rkirei[i]=rkirei[i-1]+kirei[i];
}



ll g2=min(N,s-2);

while(s2<g2) {
    ll k=(s2+g2+1)/2;
    if(rkirei[k-1]<K) {
        s2=k;
    }
    else {
        g2=k-1;
    }
}

K-=rkirei[s2-1];


vector<ll> oi(s-s2,0);

ll s3=max(1LL,s-s2-N);

for(ll i=s3;i<=min(N,s-s2-1);i++) {
    oi[i]=1;
}

vector<ll> roi(s-s2,0);
for(ll i=s3;i<=min(N,s-s2-1);i++) {
    roi[i]=roi[i-1]+oi[i];
}
ll g3=min(N,s-s2-1);


while(s3<g3) {
    ll k=(s3+g3+1)/2;

    if(roi[k-1]<K) {
        s3=k;
    }
    else {
        g3=k-1;
    }
}


cout<<s2<<" "<<s3<<" "<<s-s2-s3<<endl;
}









