public static void main ( String [ ] args ) {
  Scanner sc = new Scanner ( System . in ) ;
  PrintWriter out = new PrintWriter ( System . out ) ;
  int tc = 1 ;
  while ( tc -- > 0 ) {
    int hh = sc . nextInt ( ) ;
    int mm = sc . nextInt ( ) ;
    float h = sc . nextFloat ( ) ;
    float d = sc . nextFloat ( ) ;
    float c = sc . nextFloat ( ) ;
    float n = sc . nextFloat ( ) ;
    float ans = ( float ) ( Math . ceil ( h / n ) * c ) ;
    float ans1 ;
    if ( hh >= 20 ) {
      ans = 8 * ( ans ) / 10 ;
    }
    if ( hh < 20 ) {
      float points = ( 60 - mm + ( 19 - hh ) * 60 ) * d ;
      h += ( float ) points ;
    }
    ans1 = ( float ) Math . ceil ( h / n ) ;
    ans1 = c * ans1 * 8 / 10 ;
    System . out . println ( String . format ( "%.4f" , Math . min ( ans , ans1 ) ) ) ;
  }
  out . close ( ) ;
  sc . close ( ) ;
}

public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tc = 1 ; while ( tc -- > 0 ) { int hh = sc . nextInt ( ) ; int mm = sc . nextInt ( ) ; float h = sc . nextFloat ( ) ; float d = sc . nextFloat ( ) ; float c = sc . nextFloat ( ) ; float n = sc . nextFloat ( ) ; float ans = ( float ) ( Math . ceil ( h / n ) * c ) ; float ans1 ; if ( hh >= 20 ) { ans = 8 * ( ans ) / 10 ; } if ( hh < 20 ) { float points = ( 60 - mm + ( 19 - hh ) * 60 ) * d ; h += ( float ) points ; } ans1 = ( float ) Math . ceil ( h / n ) ; ans1 = c * ans1 * 8 / 10 ; System . out . println ( String . format ( " % .4f " , Math . min ( ans , ans1 ) ) ) ; } out . close ( ) ; sc . close ( ) ; }
(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: (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: (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: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (cast_expression type: (floating_point_type) value: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))) right: (identifier)))))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (parenthesized_expression (identifier))) right: (decimal_integer_literal)))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (block (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (decimal_integer_literal) right: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (decimal_integer_literal)))) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (floating_point_type) value: (identifier)))))) (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (floating_point_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (decimal_integer_literal)) right: (decimal_integer_literal)))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (string_literal) (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))))