Oops… KmA is already a QuantityType…
var KmC = KmA - new QuantityType(KmB.toString + KmA.unit.toString)
I have exactly the same rule, but in Jython!