long m,s,i=5e4;main(j){scanf("%ld",&m);for(s=m;--i;s=m%i?s:fmin(i+j+m/i/j-3,s))for(j=sqrt(m/i)+2;m%i