import java.lang.Exception

fun main(args:Array<String>?): Unit {
    while(true){
        val query = readLine()!!.trim()
        if (query == "#") return
        println(
                if (canReach(query)) "Yes" else "No"
        )
    }
}
fun canReach(order: String): Boolean {
    tailrec fun sub(current: Town, path: Int): Boolean {
        return if (path == order.length) current.isGoal
        else sub(current.moveTo(order[path]), path + 1)
    }
    return sub(Town.A, 0)
}

sealed class Town {
    open fun moveTo(path: Char): Town = throw Exception()
    open val isGoal: Boolean = false
    object Outer: Town() {
        override fun moveTo(path: Char): Town {
            return this
        }
    }
    object A: Town() {
        override fun moveTo(path: Char): Town {
            return when(path){
                '0' -> X
                '1' -> Y
                else -> super.moveTo(path)
            }
        }
    }
    object X: Town() {
        override fun moveTo(path: Char): Town {
            return when(path){
                '0' -> Outer
                '1' -> Z
                else -> super.moveTo(path)
            }
        }
    }
    object Y: Town() {
        override fun moveTo(path: Char): Town {
            return when(path){
                '0' -> X
                '1' -> Outer
                else -> super.moveTo(path)
            }
        }
    }
    object Z: Town(){
        override fun moveTo(path: Char): Town {
            return when(path){
                '0' -> W
                '1' -> B
                else -> super.moveTo(path)
            }
        }
    }
    object W: Town() {
        override fun moveTo(path: Char): Town {
            return when(path){
                '0' -> B
                '1' -> Y
                else -> super.moveTo(path)
            }
        }
    }
    object B: Town() {
        override val isGoal: Boolean
            get() = true
        override fun moveTo(path: Char): Town {
            return when(path){
                '0' -> Y
                '1' -> X
                else -> super.moveTo(path)
            }
        }
    }
}
