#include <iostream>
#include <fstream>

using namespace std;

int bw (int n)
{
	if (n < 2) {
		return n;
	}
	return n%2 + bw(n/2);
}

int main()
{
	ifstream in("data3.txt");
	ofstream out("out3.txt");

	for (int c = 0; c < 5; ++c)
	{
		int n;
		in >> n;
		int w = bw(n);
		do
		{
			++n;
		} while (bw(n) != w);
		out << n << endl;
	}

	return 0;
}
