#include<iostream>
using namespace std;
#define INF 100000000
int main(){
  int n,m;
  cin >> n >> m;
  int data[n+1][n+1],a,b,c,d;
  char s;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++) data[i][j] = INF;
  }
  for(int i=0;i<m;i++){
    cin >> a >> s >> b >> s >> c >> s >> d;
    data[a][b] = c;
    data[b][a] = d;
  }
  for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	data[i][j] = min(data[i][j],data[i][k]+data[k][j]);
      }
    }
  }
  /*for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++) cout << data[i][j] << ' ';
    cout << endl;
    }*/
  int x,x2,y,y2;
  cin >> x >> s >> x2 >> s >> y >> s >> y2;
  cout << y - data[x][x2] - data[x2][x] - y2 << endl;
  return 0;
} 