#include<bits/stdc++.h>
#define inf ((1<<30)-1)
#define linf ((1<<62)ll-1)
#define LL long long
#define F(i,a,b,c) for(register int i=(a);(b);i=(c))
#define Fu(i,a,b) for(register int i=(a);i<=(b);++i)
#define Fd(i,a,b) for(register int i=(a);i>=(b);--i)
#define Fn(i,a) for(register int i=las[(a)];i;i=nex[i])
#define COND(c) (isprint(c))
int Fl,ch;template<typename t>int in(t&a){a=0;ch=getchar();Fl=1;while(((ch<'0')||(ch>'9'))&&ch!=EOF)Fl=(ch=='-')?-Fl:Fl,ch=getchar();if(ch==EOF)return 0;while((ch>='0')&&(ch<='9'))a=a*10+ch-'0',ch=getchar();a*=Fl;return 1;}template<typename t,typename ...ARGS>int in(t&a,ARGS&...args){return in(a)+in(args...);}
using namespace std;
LL pri[17]={0,2,3,5,7,11,13,17,19,23,29,31,61,24251,2147483647,998244353};//46856248255981
typedef long double lb;
const lb dx=1e-8;
inline LL mul(LL x,LL y,LL mod)
{
LL tmp=(x*y-(LL)((lb)x/mod*y+dx)*mod);
return tmp<0?tmp+mod:tmp;
}
inline LL ksm(LL x,LL y,LL mod)
{
LL ans=1;
for(;y;(ans=(y&1)?mul(ans,x,mod):ans),(x=mul(x,x,mod)),y>>=1);
return ans;
}
bool MR(LL n)
{
if(n==2)return 1;
if(n==1||!(n&1))return 0;
LL cnt=0,m=n-1;
while(!(m&1))m>>=1,++cnt;
Fu(i,1,15)
{
LL a=pri[i],x=ksm(pri[i],m,n),y;
Fu(j,1,cnt)
{
y=mul(x,x,n);
if(x!=1&&x!=n-1&&y==1)return 0;
x=y;
}
if(y!=1)return 0;
}
return 1;
}
int main()
{
LL t;
while(scanf("%lld",&t)==1)
{
if(MR(t)==1)puts("Y");
else puts("N");
}
return 0;
}
//BY Segment_Tree_Juruo (2020严誉沣)
/*
*/
55分,输入数据是809183111090275843
,我错了,应该输出Y
,为什么出错啦/kel