This is basically Coppersmith on $d$