double s,p;ll i,j,n,x[3d6];{rd(n,p);for(;j>n?s+=pow(1-p,~x[++i]),j=i%~-n:--x[j-=~i];);wt(s);}