ll@N,@M,m,r,s,t;if(N<2)wt("NaN");else{s=Isqrt(N);m=s-1;if(s*s==N)wt(M/m*s+(M%m?M%m:-1));else{t=1,r=M*2d6;while(tN?r:t)=m;wt((M*N+t)/(N-1));}}