# Arup Guha
# 10/11/2021
# Solution to 2021 UCF Locals Problem: Fibrooji Sequence

# Just start the list off.
vals = [int(x) for x in input().split()]

# Loop control is done elsewhere.
while True:

    # Get the next number in the sequence.
    sz = len(vals)
    vals.append((vals[sz-1]+vals[sz-2])%10)

    # Check if we have both the first two terms.
    if vals[0] == vals[sz-1] and vals[1] == vals[sz]:
        break

# We just need the length here.
print(len(vals))
