public static void main ( String [ ] args ) {
  try {
    System . setIn ( new FileInputStream ( "input.txt" ) ) ;
    System . setOut ( new PrintStream ( new FileOutputStream ( "output.txt" ) ) ) ;
  }
  catch ( Exception e ) {
    System . err . println ( "Error" ) ;
  }
  FastReader objScanner = new FastReader ( ) ;
  int arr [ ] [ ] = new int [ 6 ] [ 6 ] ;
  int x = - 1 ;
  int y = - 1 ;
  for ( int i = 1 ;
  i <= 5 ;
  i ++ ) {
    for ( int j = 1 ;
    j <= 5 ;
    j ++ ) {
      arr [ i ] [ j ] = objScanner . nextInt ( ) ;
      if ( arr [ i ] [ j ] == 1 ) {
        x = i ;
        y = j ;
      }
    }
  }
  System . out . println ( Math . abs ( x - 3 ) + Math . abs ( y - 3 ) ) ;
}

public static void main ( String [ ] args ) { try { System . setIn ( new FileInputStream ( " input . txt " ) ) ; System . setOut ( new PrintStream ( new FileOutputStream ( " output . txt " ) ) ) ; } catch ( Exception e ) { System . err . println ( " Error " ) ; } FastReader objScanner = new FastReader ( ) ; int arr [ ] [ ] = new int [ 6 ] [ 6 ] ; int x = - 1 ; int y = - 1 ; for ( int i = 1 ; i <= 5 ; i ++ ) { for ( int j = 1 ; j <= 5 ; j ++ ) { arr [ i ] [ j ] = objScanner . nextInt ( ) ; if ( arr [ i ] [ j ] == 1 ) { x = i ; y = j ; } } } System . out . println ( Math . abs ( x - 3 ) + Math . abs ( y - 3 ) ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (try_statement body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))))))) (catch_clause (catch_formal_parameter (catch_type (type_identifier)) name: (identifier)) body: (block (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (string_literal))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal)) dimensions: (dimensions_expr (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (unary_expression operand: (decimal_integer_literal)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal))))))))))