#include<iostream>
#define N 20
#define M 10000

using namespace std;

int data[N][N];

void Init(){
  for(int i=0; i<N; ++i){
    for(int j=0; j<N; ++j){
      if(i == j) data[i][j] = 0;
      else data[i][j] = M;
    }
  }
}

void InputData(int* a, int* b, int* c, int* d){
  char dm;
  cin >> *a >> dm >> *b >> dm >> *c >> dm >> *d;
  --*a;
  --*b;
}

void WarshallFloyd(int& n){
  for(int k=0; k<n; ++k){
    for(int i=0; i<n; ++i){
      for(int j=0; j<n; ++j){
	data[i][j] = min(data[i][j], data[i][k] + data[k][j]);
      }
    }
  }
}

int main(){
  int n, m;
  int a, b, c, d;
  int x1, x2, y1, y2;
  char dm;

  Init();
  cin >> n >> m;

  for(int i=0; i<m; ++i){
    InputData(&a, &b, &c, &d);
    data[a][b] = c;
    data[b][a] = d;
  }

  WarshallFloyd(n);
  InputData(&x1, &x2, &y1, &y2);

  cout << (y1 - (y2 + data[x1][x2] + data[x2][x1])) << endl;
  return 0;
}