#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n[3], t[3];
  cin >> k >> n[0] >> n[1] >> n[2] >> t[0] >> t[1] >> t[2];
  size_t c1 = n[0], c2 = n[1], c3 = n[2];
  queue<pair<size_t, size_t> > ps1;
  queue<pair<size_t, size_t> > ps2;
  queue<pair<size_t, size_t> > ps3;
  int sec = 0;
  int notDone = k;
  while (notDone) {
    while (!ps3.empty() && ps3.front().first == sec) {
      c3 += ps3.front().second;
      notDone -= ps3.front().second;
      ps3.pop();
    }
    while (!ps2.empty() && ps2.front().first <= sec && c3) {
      size_t mn = min(ps2.front().second, c3);
      ps2.front().second -= mn;
      c3 -= mn;
      c2 += mn;
      ps3.push(make_pair(sec + t[2], mn));
      if (ps2.front().second == 0) {
        ps2.pop();
      }
    }
    while (!ps1.empty() && ps1.front().first <= sec && c2) {
      size_t mn = min(ps1.front().second, c2);
      ps1.front().second -= mn;
      c2 -= mn;
      c1 += mn;
      ps2.push(make_pair(sec + t[1], mn));
      if (ps1.front().second == 0) {
        ps1.pop();
      }
    }
    if (c1) {
      size_t mn = min(c1, (size_t)k);
      k -= mn;
      c1 -= mn;
      ps1.push(make_pair(sec + t[0], mn));
    }
    ++sec;
  }
  cout << sec - 1 << endl;
}
