
fun main(args:Array<String>):Unit {
    while(true){
        val a = readLine()!!.trim().toInt()
        if (a == 0) return
        val b = Array(4){readLine()!!.trim().toInt()}
        val arg = Array(4){0}
        arg[a]++
        b.forEach{arg[it]++}
        if (arg.count{it != 0}.let{it == 1 || it == 3}) {
            repeat(5){println(3)}
        }else{
            val first = arg.indexOfFirst { it != 0 }
            val last = arg.indexOfLast { it != 0 }
            if (last - first == 1) {
                arg[first] = 1
                arg[last] = 2
            }else{
                arg[first] = 2
                arg[last] = 1
            }
            println(arg[a])
            b.forEach{println(arg[it])}
        }
    }
}
