N = int(input()) idx = 1 vprv, v = 0, 1 % N while v: idx += 1 vnxt = vprv + v vprv = v v = vnxt % N print(idx)