Expand and re-arrange the integral into:

.

Evaluate each integral using the formula here: Beta Integral -- from Wolfram MathWorld

Simplify the resulting expression using the formula here: Beta Function -- from Wolfram MathWorld

You now have a simple quadratic function in d. Find the value of d that minimises this quadratic.