using System; using static System.Console; using System.Linq; using System.Collections.Generic; using System.Runtime.Intrinsics.Arm; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var a = new long[5]; for (var i = 0; i < 5; ++i) a[4 - i] = long.Parse(ReadLine()); var max = a.Max(); var fib = new List{ 1, 1 }; while (fib[^1] <= max) fib.Add(fib[^2] + fib[^1]); var ans = 0; for (var i = 0; i < fib.Count; ++i) { if (a[0] != fib[i]) continue; var tmp = 1; for (var j = 1; j < a.Length; ++j) { if (a[j] == fib[i + j]) ++tmp; else break; } ans = Math.Max(ans, tmp); } WriteLine(ans); } }