a[40000],m=2e4,n,i,j,k,s=1;main(x){a[1]=a[20001]=1;for(scanf("%d",&n);!a[n]&&s;x++){for(s=i=0;i++n|a[i+j]||a[i+j+m]++|s++;i