import java.io.*;
// The "Q2" class.
public class Q2
{
    public static void main (String[] args) throws IOException
    {
	BufferedReader in = new BufferedReader (new FileReader ("DATA2.txt"));
	PrintWriter out = new PrintWriter (new FileWriter ("OUT2.txt"));
	String temp;
	long f[] = new long [47];
	f [0] = 0;
	f [1] = 1;
	for (int j = 2 ; j <= 46 ; j++)
	{
	    f [j] = f [j - 1] + f [j - 2];
	}
	for (int i = 0 ; i < 5 ; i++)
	{
	    temp = in.readLine ();
	    int target = Integer.parseInt (temp);
	    for (int j = 1 ; j <= 46 ; j++)
	    {
		if (f [j] >= target)
		{
		    if (Math.abs (target - f [j - 1]) >= Math.abs (target - f [j]))
			out.println (f [j]);
		    else
			out.println (f [j - 1]);
		    break;
		}
	    }

	}
	out.close ();
	// Place your code here
    } // main method
} // Q2 class

