public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  dekiru = false ;
  R = sc . nextLong ( ) ;
  B = sc . nextLong ( ) ;
  aka_hon = sc . nextLong ( ) ;
  ao_hon = sc . nextLong ( ) ;
  dekiru_max = Math . max ( R , B ) ;
  min = 0 ;
  long mid = ( min + dekiru_max ) / 2 ;
  while ( dekiru_max > 1 + min ) {
    dekiru = false ;
    mid = ( min + dekiru_max ) / 2 ;
    dekiru = Solve ( R , B , aka_hon , ao_hon , mid ) ;
    if ( dekiru == true ) {
      min = mid ;
    }
    else if ( dekiru == false ) {
      dekiru_max = mid ;
    }
  }
  System . out . println ( ( min + dekiru_max ) / 2 ) ;
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; dekiru = false ; R = sc . nextLong ( ) ; B = sc . nextLong ( ) ; aka_hon = sc . nextLong ( ) ; ao_hon = sc . nextLong ( ) ; dekiru_max = Math . max ( R , B ) ; min = 0 ; long mid = ( min + dekiru_max ) / 2 ; while ( dekiru_max > 1 + min ) { dekiru = false ; mid = ( min + dekiru_max ) / 2 ; dekiru = Solve ( R , B , aka_hon , ao_hon , mid ) ; if ( dekiru == true ) { min = mid ; } else if ( dekiru == false ) { dekiru_max = mid ; } } System . out . println ( ( min + dekiru_max ) / 2 ) ; }
(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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (false))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (binary_expression left: (decimal_integer_literal) right: (identifier)))) body: (block (expression_statement (assignment_expression left: (identifier) right: (false))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier) (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (true))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (identifier)))) alternative: (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (false))) consequence: (block (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: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)))))))