#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 100005;

LL n, m;
__int128 zh(__int128 x) {
    return x * (x - 1) * (x - 2) / 6;
}
__int128 cal(__int128 x) {
    __int128 res = zh(x);
    if (x > n) res -= 3 * zh(x - n);
    if (x > 2 * n) res += 3 * zh(x - 2 * n);
    return res;
}
int main() {

    cin >> n >> m;
    LL l = 3, r = n * 3;
    while (l < r) {
        LL mid = l + r >> 1;
        if (cal(mid) >= m)
            r = mid;
        else
            l = mid + 1;
    }
    m -= cal(l - 1);
    for (int i = 1; i <= n; i++) {
        int x = max(1LL, l - i - n), y = min(n, l - i - 1);
        int len = y - x + 1;
        if (len <= 0) continue;
        if (m > len)
            m -= len;
        else {
            x += m - 1;
            printf("%d %d %d\n", i, x, l - x - i);
            break;
        }
    }
    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma comment(linker, "/stack:200000000")

using namespace std;
using namespace __gnu_pbds;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define eb emplace_back 
#define ppb pop_back
#define F first
#define S second
#define gcd __gcd
#define lcm(a, b) (ull(a) / gcd(a, b) * b)
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define mkp make_pair
#define mkt make_tuple
#define mem(x) memset(x, 0, sizeof(x))
#define deci(x) fixed << setprecision(x)
#define zero(x) setw(x) << setfill('0')
#define EACH(v, u) for(auto& v : u)
#define lowbit(x) (x & -x)
#define dbg(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef uint32_t uint;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
#define vt vector
#define Q queue
#define pq priority_queue
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define ar array
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vt<T>, greater<T>>;
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class T, class U> ostream& operator<<(ostream& os, pair<T, U> p) { return os << p.F << " " << p.S; }
template<class T> ostream& operator<<(ostream& os, vt<T> v) { EACH(u, v) os << u << " "; return os; }

template<class T> void read(T& x) { cin >> x; }
template<class T, class... U> void read(T& a, U&... b) { read(a), read(b...); }
template<class T> void write(T x) { cout << x;}
template<class T, class... U> void write(T a, U... b) { write(a), write(" "), write(b...), write("\n"); }

string operator*(string a, int x) { string ret = a; for(int i = 1; i < x; ++i) ret += a; return ret; }
string& operator*=(string& a, int x) { return a = a * x; }

ull fpm(ull a, ull b, ull m) { ull ret = 1;	while(b) { if(b & 1) ret = ret * ret % m; a = a * a % m; b >>= 1; } return ret; }

const int INF(1e9);
const ll LINF(1e17);
const ld pi(3.141592653589793238);

const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, d8j[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
	fastio;
	int a, b, c;
	cin >> a >> b;
	if(a == b)
		cout << a << "\n";
	else {
		c = 0 ^ 1 ^ 2 ^ a ^ b;
		cout << c << "\n";
	}
	
	return 0;
}
