• Source
    1. //solved by Anjan Diyora
    2.  
    3. import java.util.Scanner;
    4.  
    5. class problem263 {
    6. public static void main(String[] args)
    7. {
    8. Scanner sc= new Scanner(System.in);
    9. int x= 3;
    10. int y= 3;
    11. int row1= 0;
    12. int column1= 0;
    13. for(int i1=1;i1<=5;i1++)
    14. {
    15. String s= sc.nextLine().replace(" ","");
    16. if (s.contains("1"))
    17. {
    18. row1= i1;
    19. column1= s.indexOf("1")+1;
    20. break;
    21. }
    22.  
    23. }
    24. System.out.println(Math.abs(y-row1) + Math.abs(x-column1));
    25.  
    26. }
    27. }
    28.  
    29. /*
    30.  
    31. input:
    32. ----------------------
    33. 0 0 0 0 0
    34. 0 0 0 0 1
    35. 0 0 0 0 0
    36. 0 0 0 0 0
    37. 0 0 0 0 0
    38.  
    39. ______________________
    40.  
    41. Output:
    42. ----------------------
    43. 3
    44.  
    45. ======================
    46.  
    47. input:
    48. ----------------------
    49. 0 0 0 0 0
    50. 0 0 0 0 0
    51. 0 1 0 0 0
    52. 0 0 0 0 0
    53. 0 0 0 0 0
    54.  
    55. ______________________
    56.  
    57. Output:
    58. ----------------------
    59. 1
    60.  
    61.  
    62. */