#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
typedef long long Int;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000;
const Int LINF = INF * (Int) INF;
const int MAX = 2000007;
const int MAX2 = 1000;
const int MOD = 1000000007;
int solve(VI A, int n) {
int a = -1;
int m = 4 * (n - 1);
FOR(mask, 0, 1 << m) {
VI B = A;
FOR(i,0,m) {
int j = (i + 1) % m;
int x = bool(mask & (1 << i));
int y = bool(mask & (1 << j)) ^ 1;
if (i % (n - 1) == 0) {
B[2 * x + y] --;
} else {
B[4 + x + y] --;
}
}
bool ok = true;
FOR(i,0,7)
if (B[i] < 0)
ok = false;
if (ok) {
a = max(a, min(B[4], B[6]) + B[5] / 2);
}
}
if (a == -1)
return 0;
return 1 + a / 4;
}
int main(int argc, char* argv[])
{
mt19937 rng(time(0));
VI A(7);
FOR(i,0,7)
cin >> A[i];
swap(A[2], A[3]);
swap(A[5], A[6]);
cout << solve(A, 3) + solve(A, 4) << endl;
cerr << 1.0 * clock() / CLOCKS_PER_SEC << endl;
return 0;
}