str = gets.chomp.reverse if str == "6" || str=="7" puts "No"; exit end termflg = false zeroflg = false str.chars.each_index do |i| u = str[i].to_i p [u,i,[termflg, zeroflg]] if !zeroflg if u != 2 && u != 3 && u != 4 zeroflg = true redo end str[i+1] = (str[i+1].to_i-1).to_s else if termflg && u != 0 puts "No"; exit end if u != 6 && u != 7 if u == 0 termflg = true else puts "No"; exit end end end end puts "Yes"; exit