/*
 * Copyright (C) 2016 Hiroyasu Kamo
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * ACM-ICPC 2016 Japan Domestic Contest
 *  Problem C  Bamboo Blossoms
 *
 *	Author: Hiroyasu Kamo <wd@ics.nara-wu.ac.jp>
 */

#include <utility>
#include <functional>
#include <vector>
#include <queue>
#include <iostream>
using std::pair;
using std::make_pair;
using std::greater;
using std::vector;
using std::priority_queue;
using std::cin;
using std::cout;
using std::endl;

int
dull_year(int m, int n)
{
	using	Pair1 = pair<int, int>;
	priority_queue<Pair1, vector<Pair1>, greater<Pair1>>	q;
	q.push(make_pair(m * 2, m));
	while (n > 0) {
		++ m;
		if (m == q.top().first) {
			do {
				Pair1	p = q.top();
				q.pop();
				q.push(make_pair(p.first + p.second, p.second));
			} while (m == q.top().first);
		} else {
			-- n;
			q.push(make_pair(m * 2, m));
		}
	}
	return m;
}

int
main()
{
	int	m, n;
	while (cin >> m >> n && m > 0 && n > 0) {
		cout << dull_year(m, n) << endl;
	}
	return 0;
}
