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 p = n - 1; if (a[p] == 1 && a[p - 1] == 1) { ans += 2; p -= 2; } else if (a[p] == 1) { ans += 1; p -= 1; } int pos = Arrays.binarySearch(Fib, a[p]); while (pos >= 0 && p >= 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)); } }