#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10003050;
int k, n[5], t[5], disp[5], c[5], tiempo;
int event[MAXN][5];
void agarre(int id) {
  while (disp[id] && c[id + 1] < n[id]) {
    disp[id]--;
    c[id]--;
    c[id + 1]++;
    event[tiempo + t[id]][id + 1]++;
  }
}
int main() {
  while (scanf("%d", &k) == 1) {
    memset(event, 0, sizeof event);
    memset(disp, 0, sizeof disp);
    memset(c, 0, sizeof c);
    tiempo = 0;
    for (int i = (0); i < (int)(3); i++) scanf("%d", &n[i]);
    for (int i = (0); i < (int)(3); i++) scanf("%d", &t[i]);
    c[0] = k;
    disp[0] = k;
    while (c[4] != k) {
      for (int i = (0); i < (int)(4); i++) {
        int v = event[tiempo][i];
        if (v) {
          if (i < 3) disp[i] += v;
          if (i == 3) {
            c[4] += v;
            c[3] -= v;
          }
        }
      }
      for (int rep = (0); rep < (int)(4); rep++) {
        for (int i = (0); i < (int)(4); i++) {
          agarre(i);
        }
      }
      tiempo++;
    }
    printf("%d\n", tiempo - 1);
  }
  return 0;
}
