#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int s, t, a[6], b[3];

  while(1){
    t = 0;
    for(int i = 0; i < 6; i++){
      cin >> a[i];
      t += a[i];
    }
    if(t == 0) break;
    t = 0;
    for(int i = 0; i < 3; i++){
      t += (a[i]+a[i+3])/3;
      b[i] = (a[i]+a[i+3])%3;
      a[i] = (a[i]+a[i+3])/3;
    }
    s = min(b[0], min(b[1], b[2]));
    t += s;

    for(int i = 0; i < 3; i++) b[i] -= s;
    if((b[0] >= 2 && b[1] >= 2 && a[2])
       || (a[0] && b[1] >= 2 && b[2] >= 2)
       || (b[0] >= 2 && a[1] && b[2] >= 2)) t++;

    cout << t << endl;
  }

  return 0;
}