Solve Beautiful Strings in Python2