Counting algebraic points on definable sets