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; for (int i = n - 1; i >= 0; --i) { int pos = Arrays.binarySearch(Fib, a[i]); if (pos < 0) continue; int sz = 1; while (i - sz >= 0 && pos + sz < Fib.length && Fib[pos + sz] == a[i - sz]) ++sz; if (i + 1 < n && a[i + 1] == 1) ++sz; ans = Math.max(ans, sz); } System.out.println(ans); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }