  Although gravitational actions diverge in asymptotically AdS spacetimes,
boundary counterterms can be added in order to cancel out those divergences;
such counterterms are known in general to third order in the Riemann tensor for
the Einstein-Hilbert action. Considering foliations of AdS with an $S^m \times
H^{d-m}$ boundary, we discuss a simple algorithm which we use to generate
counterterms up to sixth order in the Riemann tensor, for the Einstein-Hilbert,
Gauss-Bonnet and third-order-Lovelock Lagrangians. We also comment on other
theories such as $F(R)$ gravity.
