import math a_list = [int(input()) for i in range(5)] def fibonacci(n): return round((pow((1 + math.sqrt(5)) / 2, n) - pow((1 - math.sqrt(5)) / 2, n)) / math.sqrt(5)) count = 0 for n in range(71): if a_list[-1] == fibonacci(n): count += 1 if a_list[-1] == 1 and a_list[-2] == 2: n += 1 temp = 2 for i in range(n + 1, n + 5): if a_list[-temp] == fibonacci(i): count += 1 temp += 1 else: break break print(count)