import sys F = [1, 1] n = 1 limit = 10 ** 15 i = 2 while True: v = F[i - 1] + F[i - 2] if v > limit: break F.append(v) i += 1 input = sys.stdin.readlines() A = [int(s) for s in input] A.reverse() k = len(A) ans = 0 if k >= 2 and A[0] == 1 and A[1] == 2: x = 2 y = 3 ans = 2 while x < k: if not A[x] == F[y]: break ans += 1 x += 1 y += 1 else: i = 0 if A[i] in F: j = F.index(A[i]) t = 0 while i < k and j < len(F) and A[i] == F[j]: ans += 1 i += 1 j += 1 ans = max(ans, t) print(ans)