def func(n): if n in [1,2]: return 1 if memo[n] == 0: memo[n] = func(n-1)+func(n-2) return memo[n] A = [int(input()) for _ in range(5)] memo = [0 for _ in range(10**4)] i = 1 cnt = 0 ans = 0 while 1: if func(i) == A[4]: for j in range(5): if func(i+j) == A[4-j]: cnt += 1 ans = max(ans,cnt) cnt = 0 if func(i) > max(A): break i += 1 print(ans)