import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Fibonacci {
 
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int f1 = 0;
        int f2 = 1;
        int temp;
        while(f2 < n) {
            temp = f1;
            f1 = f2;
            f2 = f1 + temp;
        }
        System.out.println(Math.min(n-f1, f2-n));
    }
}

 


ps:想想如果输入的数字最大为多少?
posted on 2018-10-25 18:16  天堂里的另一天  阅读(160)  评论(0)    收藏  举报