We model the problem using the provided graph. Each vertice with a knight, we supply with flow $1$. Each vertex has capacity $C$, each edge has capacity $1$. We connect all edges leading out of the caves to the target. Our result is simply the maximum flow.