added code for UVA:543

Please see the Problem.txt in repository.