#include <stdio.h>#include <stdlib.h>int main(){ int n,a,b,c,d,e,f,x,y,n_b; int s_2[4]={0,5,3,1}; int s_1[4]={0,7,6,5}; while(1) { scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f); if(a+b+c+d+e+f==0) break; n=f+e+d+(c+3)/4; x=d*5+s_2[c%4]; if(x<b) { n_b=(b-x+8)/9; n=n_b+n; y=e*11+s_1[c%4]+n_b*36-(b-x)*4; } else y=e*11+s_1[c%4]+(x-b)*4; if(y<a)n+=(a-y+35)/36; printf("%dn",n); } return 0;}


