CP to buy KCS