Analysis of the reaction K−p → K−π−π+p at 40 GeV/c