p=int(input()) M=N=p l=[1]*N for i in range(2,N): l[i]=-(M//i)*l[M%i]%M ans=ni=1 for i in range(1,p): ni*=i ni%=p ans+=l[ni] ans%=p print(ans)