#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define _ <<' '<<
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 3000005
//<<fixed << setprecision(9)

int arr[space];
int n;
int ways(int x)
{
    x-=2;
    if(x>n-1)
    {
        int diff=x-(n-1);
        x-=2*diff;
    }
    return x+1;
}
int32_t main()
{
    int i,j,t;
    boost;
    // n=10;
    // cin>>i;
    // cout<<ways(i);
    int k;
    cin>>n>>k;

    int ab;
    rep(ab,2,2*n+1)
    {
        int w = ways(ab);
        arr[ab+1]+=w;
        arr[ab+n+1]-=w;
    }
    rep(i,1,3*n+1) arr[i]+=arr[i-1];

    rep(i,1,3*n+1)
    {
        if(arr[i]<k)k-=arr[i];
        else break;
    }
    int sum=i;
    int bea,tas;
    rep(bea,1,n+1)
    {
        if(bea+n+n<sum )continue;

        int jmin,jmax;
        int l=1,r=n,ans;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(bea+mid+n>=sum)
            {
                r=mid-1;
                ans=mid;
            }
            else l=mid+1;
        }
        jmin=ans;

        l=1,r=n,ans;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(bea+mid+1<=sum)
            {
                l=mid+1;
                ans=mid;
            }
            else r=mid-1;
        }
        jmax=ans;

        if(k>(jmax-jmin+1)) k-= (jmax-jmin+1);
        else
        {
            tas = jmin +k-1;
            break;
        }
    }
    cout<<bea _ tas _ sum-bea-tas;
    return 0;
}
#include<bits/stdc++.h> 
#define int long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define endl "\n"

using namespace std;

const int max_n = 1e6+100;
const int limit = 2e5+10;
const int max_k = 1e7+10;
const long long inf = 1e18;
const int off_set = 1e3+10;
const int Mod = 200;

int dp[3*max_n][4];
int p[3*max_n][4];

int intersection(pair<int,int> a,pair<int,int> b){
    if(a.x>b.y || a.y<b.x) return 0;
    pair<int,int> c(max(a.x,b.x),min(a.y,b.y));
    return c.y-c.x+1;
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n,k;cin>>n>>k;
    k--;

    dp[0][0]=1;
    for(int s=0;s<=3*n;s++) p[s][0]=1;

    for(int j=1;j<=3;j++){
        for(int s=1;s<=3*n;s++){
            dp[s][j]=p[s-1][j-1];
            if(s-n-1>=0){
                dp[s][j]-=p[s-n-1][j-1];
            }

            p[s][j]=dp[s][j];
            p[s][j]+=p[s-1][j];
        }
    }

    int S;
    for(int s=1;s<=3*n;s++){
        if(dp[s][3]>k){
            S = s;
            break;
        }else{
            k-=dp[s][3];
        }
    }
    
    for(int i=1;i<=n;i++){
        pair<int,int> I1(1,n);
        pair<int,int> I2(S-i-n,S-i-1);

        int c = intersection(I1,I2);

        if(c<=k){
            k-=c;
        }else{
            for(int j=1;j<=n;j++) if(S-i-j>=1 && S-i-j<=n){
                if(k==0){
                    cout<<i<<" "<<j<<" "<<S-i-j<<endl;
                    return 0;
                }else{
                    k--;
                }
            }
            assert(false);
        }

    }

}