public static void main ( String args [ ] ) throws IOException {
  Scanner sc = new Scanner ( System . in ) ;
  int hh = sc . nextInt ( ) ;
  int mm = sc . nextInt ( ) ;
  int h = sc . nextInt ( ) ;
  int d = sc . nextInt ( ) ;
  int c = sc . nextInt ( ) ;
  int n = sc . nextInt ( ) ;
  int time = hh * 60 + mm ;
  double res1 = 0 , res2 = 0 ;
  int buns = 0 ;
  buns = ( int ) Math . ceil ( ( double ) h / n ) ;
  res1 = buns * c ;
  double res3 = res1 * 0.8 ;
  int nh = h + ( 1200 - time ) * d ;
  buns = ( int ) Math . ceil ( ( double ) nh / n ) ;
  res2 = ( buns * c ) * 0.8 ;
  double res = 0.0 ;
  if ( time >= 1200 ) res = res3 ;
  else res = Math . min ( res1 , res2 ) ;
  System . out . println ( res ) ;
}

public static void main ( String args [ ] ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int hh = sc . nextInt ( ) ; int mm = sc . nextInt ( ) ; int h = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int time = hh * 60 + mm ; double res1 = 0 , res2 = 0 ; int buns = 0 ; buns = ( int ) Math . ceil ( ( double ) h / n ) ; res1 = buns * c ; double res3 = res1 * 0.8 ; int nh = h + ( 1200 - time ) * d ; buns = ( int ) Math . ceil ( ( double ) nh / n ) ; res2 = ( buns * c ) * 0.8 ; double res = 0.0 ; if ( time >= 1200 ) res = res3 ; else res = Math . min ( res1 , res2 ) ; System . out . println ( res ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier) dimensions: (dimensions))) (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 (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)))) (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: (binary_expression left: (binary_expression left: (identifier) right: (decimal_integer_literal)) right: (identifier)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal)) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (cast_expression type: (floating_point_type) value: (identifier)) right: (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_floating_point_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (decimal_integer_literal) right: (identifier))) right: (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (cast_expression type: (integral_type) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (binary_expression left: (cast_expression type: (floating_point_type) value: (identifier)) right: (identifier))))))) (expression_statement (assignment_expression left: (identifier) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (decimal_floating_point_literal)))) (local_variable_declaration type: (floating_point_type) declarator: (variable_declarator name: (identifier) value: (decimal_floating_point_literal))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (identifier))) alternative: (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (identifier))))))