#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    int N, M, Ai1, Ai2,Ai3, i, Xi, Yi, Wi, Zi, b1, b2, b3, b;
    cin>> N>> M;
    cin>> Ai1;
    cin>> Ai2;
    cin>>Ai3;
    cin>> Xi>> Yi;
    cin>> Zi>>Wi;
    Zi=Yi;
    b1= Ai1*(Yi-Xi);
    b2= Ai2*(Wi-Xi);
    b3=Ai3*(Wi-Zi);
    b= abs (b1+b2+b3);

    cout << b<< endl;
    return 0;
}