Google code jam 2009 1C problem A