p=int(input()) O=abs(False) # 0 I=abs(True) # 1 II=abs(~True) # 2 III=sum([I,II]) # 3 a=II if p!=II else III # a=2 if p!=2 else 3 if pow(a,~-p,p)==I and p!=sum((ord('»'),ord('»'),ord('»'))): print("YES") else: print("NO")