$tb = {
  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},
}
def solve(routes)
  city = :a
  routes.each { |route|
    city = $tb[city][route]
    return false if city.nil?
  }
  city == :b
end
while (routes = gets.strip) != "#"
  puts solve(routes.chars.map(&:to_i)) ? "Yes" : "No"
end