public static void main ( String [ ] args ) throws IOException {
  BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
  long n = Long . parseLong ( br . readLine ( ) ) ;
  PrintWriter pw = new PrintWriter ( System . out ) ;
  double x = - 0.5 + ( Math . sqrt ( 1 + 4 * n ) / 2.0 ) ;
  double y = - 81.5 + ( Math . sqrt ( 26569 + 4 * n ) / 2 ) ;
  long z = ( long ) x ;
  long s = ( long ) y ;
  boolean f = true ;
  for ( long i = s ;
  i <= z ;
  i ++ ) {
    if ( i * i + check ( i ) * i == n ) {
      f = false ;
      pw . println ( i ) ;
      break ;
    }
  }
  if ( f ) pw . println ( - 1 ) ;
  pw . flush ( ) ;
}

public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long n = Long . parseLong ( br . readLine ( ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ; double x = - 0.5 + ( Math . sqrt ( 1 + 4 * n ) / 2.0 ) ; double y = - 81.5 + ( Math . sqrt ( 26569 + 4 * n ) / 2 ) ; long z = ( long ) x ; long s = ( long ) y ; boolean f = true ; for ( long i = s ; i <= z ; i ++ ) { if ( i * i + check ( i ) * i == n ) { f = false ; pw . println ( i ) ; break ; } } if ( f ) pw . println ( - 1 ) ; pw . flush ( ) ; }
(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 (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 (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 (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (unary_expression operand: (decimal_floating_point_literal)) right: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (decimal_integer_literal) right: (binary_expression left: (decimal_integer_literal) right: (identifier))))) right: (decimal_floating_point_literal)))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (unary_expression operand: (decimal_floating_point_literal)) right: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (decimal_integer_literal) right: (binary_expression left: (decimal_integer_literal) right: (identifier))))) right: (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (integral_type) value: (identifier)))) (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) value: (true))) (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 (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (method_invocation name: (identifier) arguments: (argument_list (identifier))) right: (identifier))) right: (identifier))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (false))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (break_statement))))) (if_statement condition: (parenthesized_expression (identifier)) consequence: (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (unary_expression operand: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))