The physics
Take the boat's velocity in the water. Add the water's velocity. The sum is its velocity over the ground.
vground = vboat, water + vwater
Measure the heading θ from straight across, with upstream as plus. The across speed is vb cos θ. The speed along the river is vr − vb sin θ.
t = d / (vb cos θ) drift = (vr − vb sin θ) × t
For the least time, point straight across: t = d / vb. For no drift, point upstream with sin θ = vr / vb.
If the river beats the boat, you always drift. The least drift comes at sin θ = vb / vr.