import java.io.*;
import java.util.*;

public class p3{
	public static void main(String[] args)throws IOException{
		BufferedReader inFile = new BufferedReader(new FileReader("DATA3.txt"));
		PrintWriter outPrint = new PrintWriter(new FileWriter("OUT3.txt"));
		
		for (int i = 0; i < 5; i++){
			int start = Integer.parseInt(inFile.readLine());
			int weight = weigh(start);
			int next = start + 1;
			while (weigh(next) != weight){
				next++;
			}
			outPrint.println(next);
		}
		outPrint.close();
	}
	
	public static int weigh(int n){
		int weight = 0;
		double pow = 0;
		while (Math.pow(2.0f, pow) <= n){
			pow++;
		}
		pow--;
		while (pow >= 0){
			if (Math.pow(2.0f, pow) <= n){
				n -= Math.pow(2.0f, pow);
				weight++;
			}
			pow--;
		}
		return weight;
	}
}
