public static void main ( String [ ] $ ) {
  Scanner sc = new Scanner ( in ) ;
  long n = sc . nextLong ( ) ;
  long h = sc . nextLong ( ) ;
  long a = sc . nextLong ( ) ;
  long b = sc . nextLong ( ) ;
  long c = sc . nextLong ( ) ;
  long d = sc . nextLong ( ) ;
  long e = sc . nextLong ( ) ;
  long ans = h - e * n > 0 ? 0 : Long . MAX_VALUE ;
  for ( long i = 0 ;
  i <= n ;
  i ++ ) {
    if ( n * e - h - ( b + e ) * i < 0 ) continue ;
    long j = ( n * e - h - ( b + e ) * i ) / ( d + e ) + 1l ;
    if ( j >= 0 ) ans = min ( ans , a * i + c * j ) ;
  }
  for ( long j = 0 ;
  j < n + 1 ;
  j ++ ) {
    if ( ( n * e - h - ( d + e ) * j ) < 0 ) continue ;
    long i = ( n * e - h - ( d + e ) * j ) / ( b + e ) + 1l ;
    if ( i >= 0 ) ans = min ( ans , a * i + c * j ) ;
  }
  for ( long i = 0 ;
  i < n + 1 ;
  i ++ ) {
    long f = h + i * b - ( n - i ) * e ;
    if ( f > 0 ) ans = min ( ans , a * i ) ;
  }
  for ( long i = 0 ;
  i < n + 1 ;
  i ++ ) {
    long f = h + i * d - ( n - i ) * e ;
    if ( f > 0 ) ans = min ( ans , c * i ) ;
  }
  out . println ( ans ) ;
}

public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; long n = sc . nextLong ( ) ; long h = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long e = sc . nextLong ( ) ; long ans = h - e * n > 0 ? 0 : Long . MAX_VALUE ; for ( long i = 0 ; i <= n ; i ++ ) { if ( n * e - h - ( b + e ) * i < 0 ) continue ; long j = ( n * e - h - ( b + e ) * i ) / ( d + e ) + 1l ; if ( j >= 0 ) ans = min ( ans , a * i + c * j ) ; } for ( long j = 0 ; j < n + 1 ; j ++ ) { if ( ( n * e - h - ( d + e ) * j ) < 0 ) continue ; long i = ( n * e - h - ( d + e ) * j ) / ( b + e ) + 1l ; if ( i >= 0 ) ans = min ( ans , a * i + c * j ) ; } for ( long i = 0 ; i < n + 1 ; i ++ ) { long f = h + i * b - ( n - i ) * e ; if ( f > 0 ) ans = min ( ans , a * i ) ; } for ( long i = 0 ; i < n + 1 ; i ++ ) { long f = h + i * d - ( n - i ) * e ; if ( f > 0 ) ans = min ( ans , c * i ) ; } out . println ( ans ) ; }
(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 (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: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (ternary_expression condition: (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) right: (decimal_integer_literal)) consequence: (decimal_integer_literal) alternative: (field_access object: (identifier) field: (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 (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier))) right: (decimal_integer_literal))) consequence: (continue_statement)) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (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: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) right: (decimal_integer_literal))) consequence: (continue_statement)) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (parenthesized_expression (binary_expression left: (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (identifier)) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier)))) right: (parenthesized_expression (binary_expression left: (identifier) right: (identifier)))) right: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (binary_expression left: (identifier) right: (identifier)) right: (binary_expression left: (identifier) right: (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: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (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: (binary_expression left: (identifier) right: (decimal_integer_literal))) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (identifier) right: (binary_expression left: (identifier) right: (identifier))) right: (binary_expression left: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) right: (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier) (binary_expression left: (identifier) right: (identifier))))))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))