($N,$p)=glob<>; $P=1-$p; for(2..$N){ $i=$_; ++$_[$i+=$_]while$i<$N; $x+=$P**$_[$_] } print$x