Let $f$ be a non-negative, measurable, real-valued function defined on all of $\mathbb{R}$. Show that $f$ is Lebesgue integrable on $\mathbb{R}$ if and only if the series $\sum_{k=0}^{\infty}km(E_k)$ converges, where $E_k = \{x|k\le f(x)<k+1\}$ and $m$ denotes Lebesgue measure.
The direction $(\implies)$ is simply done by countable additivity of integration, since $E_k$'s are pairwise disjoint and we can write $$\infty>\int_{\mathbb{R}} f = \sum_{k\ge0}\int_{E_k}f\ge \sum_{k\ge0}km(E_k). $$ Hence the convergence of the series.
But I was stuck on the opposite direction and need some help. Thanks!