public static void main ( String [ ] args ) {
  int a = 0 ;
  int b = 0 ;
  int c = 0 ;
  int d = 0 ;
  String [ ] tmp = null ;
  try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) {
    tmp = br . readLine ( ) . split ( "\\s" ) ;
    a = Integer . parseInt ( tmp [ 0 ] ) ;
    b = Integer . parseInt ( tmp [ 1 ] ) ;
    c = Integer . parseInt ( tmp [ 2 ] ) ;
    d = Integer . parseInt ( tmp [ 3 ] ) ;
  }
  catch ( IOException e ) {
    e . printStackTrace ( ) ;
    System . exit ( 1 ) ;
  }
  int start = 0 ;
  int end = 0 ;
  if ( a < c ) {
    start = c ;
  }
  else {
    start = a ;
  }
  if ( b < d ) {
    end = b ;
  }
  else {
    end = d ;
  }
  int result = end - start ;
  if ( result < 0 ) {
    result = 0 ;
  }
  System . out . print ( result ) ;
}

public static void main ( String [ ] args ) { int a = 0 ; int b = 0 ; int c = 0 ; int d = 0 ; String [ ] tmp = null ; try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { tmp = br . readLine ( ) . split ( " \\ s " ) ; a = Integer . parseInt ( tmp [ 0 ] ) ; b = Integer . parseInt ( tmp [ 1 ] ) ; c = Integer . parseInt ( tmp [ 2 ] ) ; d = Integer . parseInt ( tmp [ 3 ] ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } int start = 0 ; int end = 0 ; if ( a < c ) { start = c ; } else { start = a ; } if ( b < d ) { end = b ; } else { end = d ; } int result = end - start ; if ( result < 0 ) { result = 0 ; } System . out . print ( result ) ; }
(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 (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (null_literal))) (try_with_resources_statement resources: (resource_specification (resource type: (type_identifier) name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) body: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal))))))) (catch_clause (catch_formal_parameter (catch_type (type_identifier)) name: (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (decimal_integer_literal))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier)))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier)))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))