import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines *A, = map(int,read().split()) A.reverse() F = [1,1] for _ in range(100): F.append(F[-1] + F[-2]) answer = 0 for n in range(1,6): seq = A[:n] for j in range(90): if seq == F[j:j+n]: answer = n print(answer)