f = {
  :a => {
    '0' => :x,
    '1' => :y
  },
  :x => {
    '0' => nil,
    '1' => :z
  },
  :y => {
    '0' => :x,
    '1' => nil
  },
  :z => {
    '0' => :w,
    '1' => :b
  },
  :w => {
    '0' => :b,
    '1' => :y
  },
  :b => {
    '0' => :y,
    '1' => :x
  },
}

loop do
  s = gets.chomp
  if s == '#'
    break
  end
  p = :a
  s.chars do |c|
    p = f[p][c]
    break unless p
  end
  puts p==:b ? 'Yes' : 'No'
end