For a graph $H$ consisting of finitely many internally disjoint paths connecting two vertices, with possibly distinct lengths, we estimate the corresponding extremal number $text{ex}(n,H)$. When the lengths of all paths have the same parity, $text{ex}(n,H)$ is $O(n^{1+1/k^ast})$, where $2k^ast$ is the size of the smallest cycle which is included in $H$ as a subgraph. We also establish the matching lower bound in the particular case of $text{ex}(n,Theta_{3,5,5})$, where $Theta_{3,5,5}$ is the graph consisting of three disjoint paths of lengths $3,5$ and $5$ connecting two vertices.