  We obtain a tight, up to a logarithmic factor, upper bound on the number of
solutions to the equation $$ \sum_{j=1}^n a_j \frac{s_j}{r_j} =a_0, \qquad $$
with variables $r_1,...,r_n$ in an arbitrary box at the origin and variables
$s_1,..., s_n$ in an essentially arbitrary translation of this box. We apply
this result to get an upper bound on the number of stochastic matrices with
rational entries of bounded height.
