n=int(input()) if n == 1: print(1) exit() v = [] x,y,z = 1,1,3 while len(v) <= 1: x,y = y, (x+y)%n if y == 0: v.append(z) z += 1 print(v[1]-v[0])