Solving the train marshalling problem by inclusion-exclusion