p = int(input()) ans = 1 t = 1 for i in range(1,p): t *= pow(i,-1,p) ans += t ans %= p print(ans % p)