#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 R[2];
void f(VI & A, int a, int b, int n, int &p) {
a /= 2;
b %= 2;
if (a == 0 && b == 0) {
A[6] --;
if (n == 0) {
A[5] --;
}
}
if (a == 1 && b == 1) {
A[4] --;
if (n == 0) {
A[5] --;
}
}
if (a != b) {
if (n == 1)
A[5] --;
else
p --;
}
}
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]);
FILL(R, -1);
FOR(a,0,4)
FOR(b,0,4)
FOR(c,0,4)
FOR(d,0,4)
FOR(n,0,2) {
int p = 0;
VI B = A;
B[a] --;
B[b] --;
B[c] --;
B[d] --;
f(B, a, b, n, p);
f(B, b, c, n, p);
f(B, c, d, n, p);
f(B, d, a, n, p);
bool ok = true;
FOR(i,0,7)
if (B[i] < 0)
ok = false;
if (!ok)
continue;
p += min(B[4], B[6]) + B[5] / 2;
R[n] = max(R[n], p);
}
Int res = 0;
FOR(n,0,2)
if (R[n] >= 0) {
res += R[n] / 4 + 1;
}
cout << res << endl;
cerr << 1.0 * clock() / CLOCKS_PER_SEC << endl;
return 0;
}