Latin America 2014 - Problem B Improved