jabloki = gets.chomp
j100 = jabloki.count("1") # количество 100-граммовых яблочек
j200 = jabloki.count("2") # 200-граммовые
weight = j100 + j200*2 # суммарный вес
# дальше сами разберетесь, все просто
divider = (j100 > 2) && (j200 > 2) ? 2 : 1
divider2 = (j100 == 0) && (j200 > 2) ? 2 : 1
divided_weight = weight / divider / divider2
puts (weight.even?) && (divided_weight.even? || (divided_weight == 0)) ? 'YES' : 'NO'
amFibG9raSA9IGdldHMuY2hvbXAKajEwMCA9IGphYmxva2kuY291bnQoIjEiKSAjINC60L7Qu9C40YfQtdGB0YLQstC+IDEwMC3Qs9GA0LDQvNC80L7QstGL0YUg0Y/QsdC70L7Rh9C10LoKajIwMCA9IGphYmxva2kuY291bnQoIjIiKSAjIDIwMC3Qs9GA0LDQvNC80L7QstGL0LUKd2VpZ2h0ID0gajEwMCArIGoyMDAqMiAJICAjINGB0YPQvNC80LDRgNC90YvQuSDQstC10YEKIyDQtNCw0LvRjNGI0LUg0YHQsNC80Lgg0YDQsNC30LHQtdGA0LXRgtC10YHRjCwg0LLRgdC1INC/0YDQvtGB0YLQvgpkaXZpZGVyID0gKGoxMDAgPiAyKSAmJiAoajIwMCA+IDIpID8gMiA6IDEgCmRpdmlkZXIyID0gKGoxMDAgPT0gMCkgJiYgKGoyMDAgPiAyKSA/IDIgOiAxCmRpdmlkZWRfd2VpZ2h0ID0gd2VpZ2h0IC8gZGl2aWRlciAvIGRpdmlkZXIyCnB1dHMgKHdlaWdodC5ldmVuPykgJiYgKGRpdmlkZWRfd2VpZ2h0LmV2ZW4/IHx8IChkaXZpZGVkX3dlaWdodCA9PSAwKSkgPyAnWUVTJyA6ICdOTyc=