#include<stdio.h>
#include<string.h>
#define N 8010
int main()
{
int i,j,k,n1,n2,n3,a[N],b[N],c[N];
while(scanf("%d%d%d",&n1,&n2,&n3)==3 && (n1 || n2 || n3))
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));k=0;
for(i=0;i<=n1;i++)
a[i]=1;
for(i=0;i<=n1;i++)
for(j=0;j<=2*n2;j+=2)
b[i+j]+=a[i];
for(i=0;i<=n1+2*n2;i++)
for(j=0;j<=5*n3;j+=5)
c[i+j]+=b[i];
for(i=0;i<=n1+2*n2+5*n3;i++)
if(c[i]==0)
{
printf("%d\n",i);
k=1;break;
}
if(k) continue;
printf("%d\n",n1+2*n2+5*n3+1);
}
return 0;
}