import java.util.*;
public class Main {
        public static void main(String[] args){
            Scanner sc=new Scanner(System.in);
            long n=sc.nextLong();
            long a=0;
            long b=1;
            long num=1;
            while(n>num){
                long c=a+b;
                a=b;
                b=c;
                num=num+c;
            }
            System.out.println(num-b);
        }
}