import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### n = ni() if n == 1: print(1) else: a = [1,1] for i in range(1000000): a.append((a[-1] + a[-2])%n) if a[-1] == 0: print(i+3) break