  Let $f_{s,k}(n)$ be the maximum possible number of $s$-term arithmetic
progressions in a sequence $a_1<a_2<\ldots<a_n$ of $n$ integers which contains
no $k$-term arithmetic progression. For all integers $k > s \geq 3$, we prove
that $$\lim_{n \to \infty} \frac{\log f_{s,k}(n)}{\log n} = 2,$$ which answers
an old question of Erd\H{o}s. In fact, we prove upper and lower bounds for
$f_{s,k}(n)$ which show that its growth is closely related to the bounds in
Szemer\'edi's theorem.
