#include <cstdio>
#include <cmath>
using namespace std;
int main() {
int a1, b1, c1, a2, b2, c2, n;
scanf("%d%d%d%d%d%d%d", &a1, &b1, &c1, &a2, &b2, &c2, &n);
float x1 = (2.f*a2*n+b2-b1)/(a1+a2)/2; //極值
if (a1 + a2 > 0) {
if (x1 > n / 2) x1 = 0;
else if (x1 < n / 2) x1 = n;
} else {
if (x1 > n) x1 = n;
if (x1 < 0) x1 = 0;
}
x1 = round(x1);
float x2 = n - x1;
printf("%.f", a1*x1*x1+b1*x1+c1+a2*x2*x2+b2*x2+c2);
return 0;
}