The Poincaré problem in the nondicritical case