By using techniques of differential geometry we answer the following open problem proposed by Chavarriga, Giacomini, Giné, and Llibre in 1999. For a given two dimensional flow, what is the maximal order of differentiability of a first integral on a canonical region in function of the order of differentiability of the flow? Moreover, we prove that for every planar polynomial differential system there exist finitely many invariant curves and singular points <inline-formula content-type="math/mathml"> <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" alttext="gamma Subscript i Baseline comma i equals 1 comma 2 comma midline-horizontal-ellipsis comma l"> <mml:semantics> <mml:mrow> <mml:msub> <mml:mi> γ </mml:mi> <mml:mi>i</mml:mi> </mml:msub> <mml:mo>,</mml:mo> <mml:mspace width="thinmathspace"/> <mml:mi>i</mml:mi> <mml:mo>=</mml:mo> <mml:mn>1</mml:mn> <mml:mo>,</mml:mo> <mml:mn>2</mml:mn> <mml:mo>,</mml:mo> <mml:mo> ⋯ </mml:mo> <mml:mo>,</mml:mo> <mml:mi>l</mml:mi> </mml:mrow> <mml:annotation encoding="application/x-tex">\gamma _i,\,i=1,2,\cdots ,l</mml:annotation> </mml:semantics> </mml:math> </inline-formula> , such that <inline-formula content-type="math/mathml"> <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" alttext="double-struck upper R squared minus left-parenthesis union Underscript i equals 1 Overscript l Endscripts gamma Subscript i Baseline right-parenthesis"> <mml:semantics> <mml:mrow> <mml:msup> <mml:mrow class="MJX-TeXAtom-ORD"> <mml:mi mathvariant="double-struck">R</mml:mi> </mml:mrow> <mml:mn>2</mml:mn> </mml:msup> <mml:mi class="MJX-variant" mathvariant="normal"> ∖ </mml:mi> <mml:mrow> <mml:mo>(</mml:mo> <mml:munderover> <mml:mo> ⋃ </mml:mo> <mml:mrow class="MJX-TeXAtom-ORD"> <mml:mi>i</mml:mi> <mml:mo>=</mml:mo> <mml:mn>1</mml:mn> </mml:mrow> <mml:mrow class="MJX-TeXAtom-ORD"> <mml:mi>l</mml:mi> </mml:mrow> </mml:munderover> <mml:msub> <mml:mi> γ </mml:mi> <mml:mi>i</mml:mi> </mml:msub> <mml:mo>)</mml:mo> </mml:mrow> </mml:mrow> <mml:annotation encoding="application/x-tex">\mathbb R^2\backslash \left (\bigcup ^{l}_{i=1}\gamma _i\right )</mml:annotation> </mml:semantics> </mml:math> </inline-formula> has finitely many connected open components, and that on each of these connected sets the system has an analytic first integral. For a homogeneous polynomial differential system in <inline-formula content-type="math/mathml"> <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" alttext="double-struck upper R cubed"> <mml:semantics> <mml:msup> <mml:mrow class="MJX-TeXAtom-ORD"> <mml:mi mathvariant="double-struck">R</mml:mi> </mml:mrow> <mml:mn>3</mml:mn> </mml:msup> <mml:annotation encoding="application/x-tex">\mathbb R^3</mml:annotation> </mml:semantics> </mml:math> </inline-formula> , there exist finitely many invariant straight lines and invariant conical surfaces such that their complement in <inline-formula content-type="math/mathml"> <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" alttext="double-struck upper R cubed"> <mml:semantics> <mml:msup> <mml:mrow class="MJX-TeXAtom-ORD"> <mml:mi mathvariant="double-struck">R</mml:mi> </mml:mrow> <mml:mn>3</mml:mn> </mml:msup> <mml:annotation encoding="application/x-tex">\mathbb R^3</mml:annotation> </mml:semantics> </mml:math> </inline-formula> is the union of finitely many open connected components, and that on each of these connected open components the system has an analytic first integral.