#include <bits/stdc++.h>
using namespace std;
int main() {
	uint64_t n, a, b; cin >> n >> a >> b;
	multiset<uint64_t> s;
	for (uint64_t m=1<<n;m;m /= 2) { if (a&m) s.insert(m); if (b&m) s.insert(m); }
	int ans = 0;
	while (*s.begin() != (1 << n)) {
		auto first = s.begin(), second = next(first);
		if (second != s.end() && *first == *second) {
			uint64_t nxt = *first + *second;
			s.erase(first); s.erase(second);
			s.insert(nxt);
		} else {
			uint64_t nxt = *first * 2;
			s.erase(first);
			s.insert(nxt);
		}
		++ans;
	}
	if (s.size() == 1) {
		cout << ans << endl;
	} else {
		cout << "impossible" << endl;
	}
}
