#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

struct info{
    ll num;
    ll cost;
};

bool operator< (const info &info1, const info &info2){
    return info1.cost<info2.cost;
}
bool operator> (const info &info1, const info &info2){
    return info1.cost>info2.cost;
}

int main(){
    ll X, Y;
    cin >> X >> Y;

    if(X>=Y){
        cout << X-Y << endl;
        return 0;
    }

    priority_queue<info, vector<info>, greater<info>> pque;
    pque.push({Y,0});
    map<ll,int> dict;

    while(!pque.empty()){
        info now=pque.top();
        //cout << now.num << ' ' << now.cost << endl;
        pque.pop();

        if(dict.count(now.num))continue;
        else{
            dict[now.num]=now.cost;
        }

        if(now.num==X){
            cout << now.cost << endl;
            return 0;
        }else if(now.num%2==0){
            pque.push({X,now.cost+abs(X-now.num)});
            pque.push({now.num/2,now.cost+1});
        }else{
            pque.push({now.num+1,now.cost+1});
            pque.push({now.num-1,now.cost+1});
        }
    }
}
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
//#define DIV 1000000007
//#define DIV 998244353
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
ll N, K;
 
ll cou0[4000005];
ll cou1[4000005];
 
ll sumi;
 
//綺麗さがiのときに何通りあるか
ll kire[4000005];
 
void pre() {
	//合計がそれぞれいくつあるか
	for(ll i = 2; i <= 2*N; i++) {
		if(i <= 1) continue;
		if(i <= N + 1) {
			cou1[i] = i-1;
			cou0[i] = i-1;
		} else {
			cou1[i] = 2*N+1-i;
			cou0[i] = 2*N+1-i;
		}
	}
	rep(i, 3*N+1) cou1[i+1] += cou1[i];
 
}
 
//3つの合計がnum以下になる君合わせ
ll get_cou(ll num) {
	ll ret = 0;
	for(ll i = 1; i <= N; i++) {
		ll maxi = num - i;
      if(maxi < 0) continue;
		ret += cou1[maxi];
	}
 
	return ret;
}
 
//合計が決まってるとき、kireの値で何通りあり得るか
void pre2() {
	for(ll ki = 1; ki <= N; ki++) {
		ll others = sumi - ki;
		if(others <= 1 || others > 2*N) continue;
		kire[ki] += cou0[others];
	}
 
	rep(i, N+5) {
		//cout << "kire[" << i << " ] = " << kire[i] << endl;
		kire[i+1] += kire[i];
	}
}
 
 
int main(){
	cin >> N >> K;
 
	pre();
 
	ll ok = 0;
	ll ng = 3*N;
	while(ok + 1 < ng) {
		ll mid = (ok + ng)/2;
		if(get_cou(mid) >= K) {
			ng = mid;
		} else {
			ok = mid;
		}
	}
	//cout << ok << endl;
 
	//三つの合計はsumi
	sumi = ok + 1;
 
	//3つの合計がsumiになるときにkireisaで何番目になるかの二部たん
	pre2();
	ll K2 = K - get_cou(ok);
	//cout << "p0 ok = " << ok << " get_cout - " << get_cou(ok) << endl;
 
	//綺麗さについて二部たん
	
	ok = 0;
	ng = N+1;
	while(ok + 1 < ng) {
		ll mid = (ok + ng)/2;
		if(kire[mid] >= K2) {
			ng = mid;
		} else {
			ok = mid;
		}
	}
	//cout << "K2 = " << K2 << " kire[" << ok << "] = " << kire[ok] << endl;
 
	ll kirev = ok + 1;
	//cout << "sumi = " << sumi << endl;
	//cout << "kirev = " << kirev << endl;
 
	ll K3 = K2 - kire[ok];
 
	//cout << "K3 = " << K3 << endl;
 
	//3つのわ, kirei, oisi, ninki
	vector<tuple<ll, ll, ll, ll> >ans;
 
	for(ll oi = 1; oi <= N; oi++) {
		ll nin = sumi - kirev - oi;
		if(nin <= 0 || nin > N) continue;
		ans.push_back({sumi, kirev, oi, nin});
	}
	sort(ans.begin(), ans.end());
	//cout << "K3 = " << K3 << " ans " << ans.size() << endl;
 
	ll _, k, o, n;
	tie(_, k, o, n) = ans[K3-1];
	cout << k << " " << o << " " << n << endl;
 
 
}
 