/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author 073795502
 */
import java.io.*;
import java.util.*;
public class FibonacciRound {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        BufferedReader f;

        try
        {
            f=new BufferedReader(new FileReader("DATA2.txt"));

            int[] num=new int[5];
            int[] roundfi=new int[5];
            Vector fibs = new Vector();

            int max=0;

            for(int i=0; i<5; i++)
            {
                num[i]=Integer.parseInt(f.readLine());

                max = num[i] > max ? num[i] : max;
            }

            int a, b, c;
            a = 0;
            b = 1;
            fibs.add((Object)a);
            fibs.add((Object) b);
            while(((Integer) fibs.get(fibs.size() - 1)) < max)
            {
                c = b;
                b = a + b;
                a = c;

                fibs.add((Object) b);
            }

            PrintWriter fo=new PrintWriter(new FileWriter("OUT2.txt"));
            for(int i = 0; i < 5; i++)
            {
                for(int j = 0; j < fibs.size(); j++)
                {
                    if(((Integer)fibs.get(j)) >= num[i])  {
                        int diff_up = (Integer)fibs.get(j) - num[i];
                        int diff_down = num[i]-(Integer) fibs.get(j - 1);

                        fo.println((diff_up <= diff_down) ? fibs.get(j) : fibs.get(j - 1));
                        break;
                    }
                }
            }

            fo.close();
        }
        catch(IOException e)
        {
        }
    }
}

