public static void main ( String [ ] args ) throws IOException {
  FastScanner fs = new FastScanner ( ) ;
  PrintWriter out = new PrintWriter ( System . out ) ;
  int tt = 1 ;
  while ( tt -- > 0 ) {
    Point p1 = new Point ( fs . nextInt ( ) , fs . nextInt ( ) ) ;
    int r1 = fs . nextInt ( ) , R1 = fs . nextInt ( ) ;
    Point p2 = new Point ( fs . nextInt ( ) , fs . nextInt ( ) ) ;
    int r2 = fs . nextInt ( ) , R2 = fs . nextInt ( ) ;
    int ans = 0 ;
    ans += intersection ( p1 , r1 , p2 , r2 , R2 ) ;
    ans += intersection ( p1 , R1 , p2 , r2 , R2 ) ;
    ans += intersection ( p2 , r2 , p1 , r1 , R1 ) ;
    ans += intersection ( p2 , R2 , p1 , r1 , R1 ) ;
    out . println ( ans ) ;
  }
  out . close ( ) ;
}

public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tt = 1 ; while ( tt -- > 0 ) { Point p1 = new Point ( fs . nextInt ( ) , fs . nextInt ( ) ) ; int r1 = fs . nextInt ( ) , R1 = fs . nextInt ( ) ; Point p2 = new Point ( fs . nextInt ( ) , fs . nextInt ( ) ) ; int r2 = fs . nextInt ( ) , R2 = fs . nextInt ( ) ; int ans = 0 ; ans += intersection ( p1 , r1 , p2 , r2 , R2 ) ; ans += intersection ( p1 , R1 , p2 , r2 , R2 ) ; ans += intersection ( p2 , r2 , p1 , r1 , R1 ) ; ans += intersection ( p2 , R2 , p1 , r1 , R1 ) ; out . println ( ans ) ; } out . close ( ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (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: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (while_statement condition: (parenthesized_expression (binary_expression left: (update_expression (identifier)) right: (decimal_integer_literal))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier) (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier) (identifier) (identifier) (identifier))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))