A monster is attacking the Cyberland!

Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).

During the battle, every second the monster's HP decrease by max(0, ATKY - DEFM), while Yang's HP decreases by max(0, ATKM - DEFY), where index Y denotes Master Yang and index M denotes monster. Both decreases happen simultaneously Once monster's HP ≤ 0 and the same time Master Yang's HP > 0, Master Yang wins.

Master Yang can buy attributes from the magic shop of Cyberland: h bitcoins per HP, a bitcoins per ATK, and d bitcoins per DEF.

Now Master Yang wants to know the minimum number of bitcoins he can spend in order to win.

Input

The first line contains three integers HPY, ATKY, DEFY, separated by a space, denoting the initial HP, ATK and DEF of Master Yang.

The second line contains three integers HPM, ATKM, DEFM, separated by a space, denoting the HP, ATK and DEF of the monster.

The third line contains three integers h, a, d, separated by a space, denoting the price of 1 HP, 1 ATK and 1 DEF.

All numbers in input are integer and lie between 1 and 100 inclusively.

Output

The only output line should contain an integer, denoting the minimum bitcoins Master Yang should spend in order to win.

Examples

Input

1 2 1
1 100 1
1 100 100


Output

99


Input

100 100 100
1 1 1
1 1 1


Output

0

Note

For the first sample, prices for ATK and DEF are extremely high. Master Yang can buy 99 HP, then he can beat the monster with 1 HP left.

For the second sample, Master Yang is strong enough to beat the monster, so he doesn't need to buy anything.
51 89 97
18 25 63
22 91 74
 1 100 1
100 100 100
1 100 100
 20 1 1
100 100 100
1 100 100
 1 10 29
1 1 43
1 1 100
 25 38 49
84 96 42
3 51 92
 2 1 1
100 2 100
100 1 100
 1 1 1
100 100 100
1 100 100
 99 32 20
89 72 74
1 100 39
 100 1 1
100 100 100
1 100 100
 10 100 55
100 100 1
1 1 1
 1 1 1
1 1 1
100 100 100
 1 1 1
1 1 1
1 1 1
 1 97 1
100 99 98
1 51 52
 50 80 92
41 51 56
75 93 12
 100 1 1
100 100 100
100 1 100
 11 1 1
100 1 1
100 1 1
 1 1 1
100 100 100
100 100 100
 1 28 47
31 60 38
14 51 77
 1 1 1
100 100 100
1 2 3
 1 100 100
1 1 1
87 100 43
 1 1 1
100 100 100
1 1 100
 14 61 87
11 78 14
5 84 92
 65 6 5
70 78 51
88 55 78
 1 100 1
100 100 99
1 100 100
 39 49 78
14 70 41
3 33 23
 11 1 1
10 1 10
100 50 1
 1 100 1
1 1 1
1 1 1
 79 1 1
1 1 10
1 1 100
 100 100 100
100 100 100
100 100 100
 11 82 51
90 84 72
98 98 43
 50 100 51
100 100 100
1 100 100
 10 100 1
100 1 1
1 100 1
 74 89 5
32 76 99
62 95 36
 72 16 49
5 21 84
48 51 88
 100 100 1
100 100 100
1 100 100
 76 63 14
89 87 35
20 15 56
 1 1 1
1 1 100
100 100 1
 1 10 10
1 10 100
1 1 61
 10 10 100
1 10 1
1 1 100
 1 1 100
1 1 1
100 1 100
 12 59 66
43 15 16
12 18 66
 10 10 100
1 100 100
10 100 90
 10 100 1
1 100 100
100 1 9

0 1990 11871 34 1692 199 11890 5478 11791 37 100 1 1498 0 199 1 19900 1562 496 0 298 0 7027 1890 0 500 0 10 100 1376 1384 0 3529 3519 1891 915 10000 91 0 1 0 9100 811
#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, x, n, flg = 0, s, att, tat, b, y, mx, cnt;
  int a[3], h[3], d[3], p[3];
  cin >> h[1] >> a[1] >> d[1] >> h[2] >> a[2] >> d[2] >> p[1] >> p[2] >> p[3];
  mx = a[2] - d[1];
  mx++;
  if (mx < 0) mx = 0;
  mx *= p[3];
  att = a[1] - d[2];
  if (att <= 0) {
    att = d[2] + 1;
    mx += (d[2] - a[1] + 1) * p[2];
  }
  while (h[2] / att > 0 || !flg) {
    s = h[2] / att;
    if (h[2] % att != 0 && flg) {
      att++;
      continue;
    }
    if (h[2] % att != 0) s++;
    if (h[2] / att == 0) {
      s++;
      flg = 1;
    }
    cnt = (att - a[1] + d[2]) * p[2];
    tat = a[2] - d[1];
    tat *= s;
    tat -= h[1];
    tat++;
    if (tat < 0) tat = 0;
    y = tat / s;
    if (tat % s != 0) y++;
    tat *= p[1];
    y *= p[3];
    cnt += min(tat, y);
    if (mx > cnt) {
      mx = cnt;
    }
    att++;
  }
  printf("%d", mx);
}
