function mostDays(x,f,d,p) { if(Math.floor(d/x)<=f) { return Math.floor(d/x); } else { return (f+(Math.floor((d-x*f)/(x+p)))); } }