import java.util.Arrays; import java.util.Comparator; import java.util.PriorityQueue; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); int n = 5; long[] a = new long[n]; for (int i = 0; i < n; ++i) a[i] = sc.nextLong(); long[] Fib = new long[74]; Fib[0] = Fib[1] = 1; for (int i = 2; i < Fib.length; ++i) { Fib[i] = Fib[i - 1] + Fib[i - 2]; } int ans = 0; int pos = Arrays.binarySearch(Fib, a[n-1]); if(a[n-1]==1&&a[n-2]==1) { pos=0; }else if(a[n-1]==1) { pos=1; } int p=n-1; while (p>=0 && pos >= 0 && Fib[pos] == a[p] && p < a.length) { ++ans; ++pos; --p; } System.out.println(ans); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }