#include<stdio.h>
main(){
int A1, B1, C1, A2, B2, C2, n, x1, x2, y1, y2, max=-9999999, m=0, i;
scanf("%d%d%d" ,&A1,&B1,&C1);
scanf("%d%d%d" ,&A2,&B2,&C2);
scanf("%d",&n);
for(i=0;i<=n;i++){
x1=i;
x2=n-x1;
y1=A1*x1*x1+B1*x1+C1;
y2=A2*x2*x2+B2*x2+C2;
m=y1+y2;
if(m>max)
max=m;
}
printf("%d",max);
}