A general cycle can be divided into small Carnot cycles. The match is exact in the limit of infinitesimally small cycles. Paths cancel in the interior of the collection, and only the perimeter, an increasingly good approximation to the true cycle as the number of cycles increases, survives. Because the entropy change around every individual cycle is zero, the integral of the entropy around the perimeter is zero too.