import java.util.Scanner;

fun main (args: Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    var varCount = 5
    
    while (varCount-- > 0) {
      if (input.nextInt() == 0) {
        println(5 - varCount)
      }
    }
  }
}