The number of paths and cycles in a digraph