import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int [][] arr = new int [5][5];
        int times = 0;
        for(int i = 0; i <= 4; i++){
            for(int j = 0; j <= 4; j++){
                arr[i][j] = sc.nextInt();
                if(arr[i][j] == 1){
                    times = Math.abs(i - 2) + Math.abs(j - 2);
                }
            }
        }
        System.out.println(times);
    }
}
这个就是将箱子的坐标减去中心坐标的绝对值之和。