L = [0] * 100 L[1] = 1 L[2] = 2 for i in range(3, 100): L[i] = L[i - 1] + L[i - 2] A = [] for i in range(5): a = int(input()) if a in L: v = L.index(a) else: v = -1 A.append(v) if A[-1] == A[-2] == 1: A[-1] = 0 if A[-1] == -1: print(0) exit() A.reverse() pre = A[0] ans = 1 for i in range(1, 5): if A[i] == pre + 1: ans += 1 pre = A[i] else: break print(ans)