public static void main ( String [ ] args ) {
  Scanner scanner = new Scanner ( System . in ) ;
  int numberOfBlocks = scanner . nextInt ( ) ;
  int circuit = - 1 ;
  int findThatHasSquare = numberOfBlocks ;
  if ( Math . sqrt ( findThatHasSquare ) % 1 == 0 ) {
    circuit = ( int ) Math . sqrt ( findThatHasSquare ) * 4 ;
  }
  else {
    findThatHasSquare = numberOfBlocks ;
    while ( true ) {
      if ( Math . sqrt ( findThatHasSquare ) % 1 == 0 ) {
        break ;
      }
      findThatHasSquare -- ;
    }
  }
  if ( circuit == - 1 ) {
    int sqrt = ( int ) Math . sqrt ( findThatHasSquare ) ;
    circuit = sqrt * 4 ;
    int restBlocks = numberOfBlocks - findThatHasSquare ;
    while ( true ) {
      if ( restBlocks - sqrt > 0 ) {
        restBlocks = - sqrt ;
        circuit += 2 ;
      }
      else {
        circuit += 2 ;
        break ;
      }
    }
  }
  System . out . println ( circuit ) ;
}

public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int numberOfBlocks = scanner . nextInt ( ) ; int circuit = - 1 ; int findThatHasSquare = numberOfBlocks ; if ( Math . sqrt ( findThatHasSquare ) % 1 == 0 ) { circuit = ( int ) Math . sqrt ( findThatHasSquare ) * 4 ; } else { findThatHasSquare = numberOfBlocks ; while ( true ) { if ( Math . sqrt ( findThatHasSquare ) % 1 == 0 ) { break ; } findThatHasSquare -- ; } } if ( circuit == - 1 ) { int sqrt = ( int ) Math . sqrt ( findThatHasSquare ) ; circuit = sqrt * 4 ; int restBlocks = numberOfBlocks - findThatHasSquare ; while ( true ) { if ( restBlocks - sqrt > 0 ) { restBlocks = - sqrt ; circuit += 2 ; } else { circuit += 2 ; break ; } } } System . out . println ( circuit ) ; }
(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: (unary_expression operand: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) right: (decimal_integer_literal))))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (identifier))) (while_statement condition: (parenthesized_expression (true)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (decimal_integer_literal)) right: (decimal_integer_literal))) consequence: (block (break_statement))) (expression_statement (update_expression (identifier))))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (unary_expression operand: (decimal_integer_literal)))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (identifier)))) (while_statement condition: (parenthesized_expression (true)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (unary_expression operand: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))) alternative: (block (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) (break_statement))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))