#include<iostream>
using namespace std;
int main(){
int A1,B1,C1,A2,B2,C2,n;
int profit1,profit2;
cin>>A1>>B1>>C1;
cin>>A2>>B2>>C2;
cin>>n;
int max=0;
int storage[n];
for(int i=0;i<=n;i++){
profit1=A1*i+B1*(n-i)+C1;
profit2=A2*(n-i)+B2*i+C2;
storage[i]=profit1+profit2;
if(storage[i]>max){
max=storage[i];
}
}
cout<<max;
return 0;
}