#include <iostream>
#include <cstdlib>

using namespace std;

int main() 
{
	int N,M,Ai,Ai2,Ai3,Xi,Xi2,Xi3,Yi,Yi2,Ain;
	cin>>N>>M;
	cin>>Ai;
	cin>>Ai2;
	cin>>Ai3;
	cin>>Xi>>Yi;
	cin>>Xi2>>Yi2;
	Ain=Ai*(2)+Ai2*(1)+Ai3*(1);
	cout<<Ain;
	system ("PAUSE>>null");
	return 0;
}