#yuki954 f=[1,1,2,3] while f[-1]<=10**15: f.append(f[-1]+f[-2]) a=[int(raw_input()) for i in range(5)] a.reverse() res=0 for i in range(6): for j in range(len(f)-i): if a[:i]==f[j:j+i]: res=max(res,i) print res