Primodial retention of carbon by the terrestrial planets