g = {
    :a => {0 => :x, 1 => :y},
    :x => {1 => :z},
    :y => {0 => :x},
    :z => {0 => :w, 1 => :b},
    :w => {0 => :b, 1 => :y},
    :b => {0 => :y, 1 => :x},
    :d => {},
}
loop do
    q = gets.chomp
    break if q == ?#
    v = :a
    q.each_char do |c|
        if g[v][c.to_i]
            v = g[v][c.to_i]
        else
            v = :d
        end
    end
    puts v == :b ? 'Yes' : 'No'
end
