import java.io.*;
import java.util.*;

public class FibRound{
	
	public static void main(String[] args){
		try{
			File infile = new File("data2.txt");
			File outfile = new File("out2.txt");
			Scanner input = new Scanner(infile);
			PrintStream ps = new PrintStream(new FileOutputStream(outfile));
			int comparedNum, fib1, fib2, temp;
			for (int i=0;i<5;i++){
				comparedNum = Integer.parseInt(input.next());
				fib1 = 0;
				fib2 = 1;
				while (comparedNum-fib2>0){
					temp = fib1+fib2;
					fib1 = fib2;
					fib2 = temp;
				}
				if (Math.abs(comparedNum-fib1)<Math.abs(comparedNum-fib2)){
					ps.println(fib1);
				} else {
					ps.println(fib2);
				}
			}
			input.close();
			ps.close();
		} catch (IOException e){
			e.printStackTrace();
		}
	}
}
