public static void main ( String [ ] args ) {
  Scanner in = new Scanner ( System . in ) ;
  int xFrom = in . nextInt ( ) ;
  int yFrom = in . nextInt ( ) ;
  int xTo = in . nextInt ( ) ;
  int yTo = in . nextInt ( ) ;
  if ( xFrom > xTo ) {
    int temp = xFrom ;
    xFrom = xTo ;
    xTo = temp ;
  }
  if ( yFrom > yTo ) {
    int temp = yFrom ;
    yFrom = yTo ;
    yTo = temp ;
  }
  int N = in . nextInt ( ) ;
  int [ ] X = new int [ N ] ;
  int [ ] Y = new int [ N ] ;
  int [ ] R = new int [ N ] ;
  for ( int n = 0 ;
  n < N ;
  n ++ ) {
    X [ n ] = in . nextInt ( ) ;
    Y [ n ] = in . nextInt ( ) ;
    R [ n ] = in . nextInt ( ) ;
  }
  List < Point > generals = new ArrayList < > ( ) ;
  for ( int x = xFrom ;
  x < xTo ;
  x ++ ) {
    generals . add ( new Point ( x , yFrom ) ) ;
  }
  for ( int y = yFrom ;
  y < yTo ;
  y ++ ) {
    generals . add ( new Point ( xTo , y ) ) ;
  }
  for ( int x = xTo ;
  x > xFrom ;
  x -- ) {
    generals . add ( new Point ( x , yTo ) ) ;
  }
  for ( int y = yTo ;
  y > yFrom ;
  y -- ) {
    generals . add ( new Point ( xFrom , y ) ) ;
  }
  int answer = 0 ;
  for ( Point p : generals ) {
    boolean heated = false ;
    for ( int n = 0 ;
    n < N ;
    n ++ ) {
      int dx = p . x - X [ n ] ;
      int dy = p . y - Y [ n ] ;
      if ( dx * dx + dy * dy <= R [ n ] * R [ n ] ) {
        heated = true ;
        break ;
      }
    }
    if ( ! heated ) {
      answer ++ ;
    }
  }
  System . out . println ( answer ) ;
}

public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int xFrom = in . nextInt ( ) ; int yFrom = in . nextInt ( ) ; int xTo = in . nextInt ( ) ; int yTo = in . nextInt ( ) ; if ( xFrom > xTo ) { int temp = xFrom ; xFrom = xTo ; xTo = temp ; } if ( yFrom > yTo ) { int temp = yFrom ; yFrom = yTo ; yTo = temp ; } int N = in . nextInt ( ) ; int [ ] X = new int [ N ] ; int [ ] Y = new int [ N ] ; int [ ] R = new int [ N ] ; for ( int n = 0 ; n < N ; n ++ ) { X [ n ] = in . nextInt ( ) ; Y [ n ] = in . nextInt ( ) ; R [ n ] = in . nextInt ( ) ; } List < Point > generals = new ArrayList < > ( ) ; for ( int x = xFrom ; x < xTo ; x ++ ) { generals . add ( new Point ( x , yFrom ) ) ; } for ( int y = yFrom ; y < yTo ; y ++ ) { generals . add ( new Point ( xTo , y ) ) ; } for ( int x = xTo ; x > xFrom ; x -- ) { generals . add ( new Point ( x , yTo ) ) ; } for ( int y = yTo ; y > yFrom ; y -- ) { generals . add ( new Point ( xFrom , y ) ) ; } int answer = 0 ; for ( Point p : generals ) { boolean heated = false ; for ( int n = 0 ; n < N ; n ++ ) { int dx = p . x - X [ n ] ; int dy = p . y - Y [ n ] ; if ( dx * dx + dy * dy <= R [ n ] * R [ n ] ) { heated = true ; break ; } } if ( ! heated ) { answer ++ ; } } System . out . println ( answer ) ; }
(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)))))) (local_variable_declaration type: (integral_type) 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: (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)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier) (identifier)))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier) (identifier)))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier) (identifier)))))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (identifier) (identifier)))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (enhanced_for_statement type: (type_identifier) name: (identifier) value: (identifier) body: (block (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (false))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (array_access array: (identifier) index: (identifier))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (field_access object: (identifier) field: (identifier)) right: (array_access array: (identifier) index: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (identifier))) right: (binary_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier))))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (true))) (break_statement))))) (if_statement condition: (parenthesized_expression (unary_expression operand: (identifier))) consequence: (block (expression_statement (update_expression (identifier))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))