#include<iostream>

using namespace std;

int main(){

  int data[6];
  while(1){
    int tmp = 0;
    for(int i = 0; i < 6; i++){
      cin >> data[i];
      tmp += data[i];
    }
    if(tmp == 0) break;
   
    int a = data[0]+data[3];
    int b = data[1]+data[4];
    int c = data[2]+data[5];

    int lim = min(2,min(a,min(b,c)));

    int ans = 0;
    for(int i = 0; i <= lim; i++) ans = max(ans,i+(a-i)/3+(b-i)/3+(c-i)/3);
    cout << ans << endl;
  }
  return 0;
}