import java.io.*;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class left3 {
	public static void main(String args[]) throws Exception {
		Scanner read = new Scanner(new File("DATA3.txt"));
		PrintWriter write = new PrintWriter(new File("OUT3.txt"));
		
		for (int i = 0; i < 5; i++){
			int love = read.nextInt();
			int hate = 0;
			String loveS = Integer.toBinaryString(love);
			int weight = loveS.length() - loveS.replaceAll("1", "").length();
			
			int tempWeight = 0;
			boolean findMode = true;
			while (findMode){
				love++;
				loveS = Integer.toBinaryString(love);
				tempWeight = loveS.length() - loveS.replaceAll("1", "").length();
				if (tempWeight == weight){
					findMode = false;
					hate = love;
				}
			}
			
			write.println(hate);
		}
		write.close();
	}
}

