Abstract : Counting lattice points inside a ball of large radius in Euclidean space is a classical problem in analytic number theory, dating back to Gauss. We propose a variation on this problem: studying the asymptotics of the measure of an integer lattice of affine planes inside a ball. The first term is the volume of the ball; we study the size of the remainder term. While the classical problem is equivalent to counting eigenvalues of the Laplace operator on the torus, our variation corresponds to the integrated density of states of the Laplace operator on the product of a torus with Euclidean space. The asymptotics we obtain are then used to compute the density of states of the magnetic Schroedinger operator.