#include<vector>
#include<algorithm>

int main() {
	std::size_t N,X;
	std::cin >> N >> X;
	auto res{0};
	if (2 * X < N) {
		res = X * 6;
	}
	else {
		res = X * 3;
	}
	std::cout << res<<"\n";
	return 0;
}