#include<stdio.h>
int main()
{
__int64 n,i,t,s;
while(scanf("%I64d",&n)!=EOF)
{
if(n%2==0)
printf("2^? mod %I64d = 1\n",n);
else if(n==1)
printf("2^0 mod %I64d = 1\n",n);
else
{
s=2;
t=1;
while(s!=1)
{
s=s*2%n;
t++;
}
printf("2^%I64d mod %I64d = 1\n",t,n);
}
}
return 0;
}