#include <iostream>
#include <algorithm>
#define INF 100000000

using namespace std;
int dd[100][100];
int v[100];
int n,m;

void init(){
  for(int i = 0 ; i < n ; i++ ){
  for(int j = 0 ; j < n ; j++ ){
    dd[i][j] = INF;
  }
  }
}

void dijkstra(int s){
  bool visited[100];
  fill(visited,visited+100,false);
  fill(v,v+100,INF);
  v[s] = 0;

  while(1){
    int vv = -1;

    for(int i = 0 ; i < n ; i++ ){
      if(!visited[i] && (vv == -1 || v[i] < v[vv]))vv = i;
    }

    if(vv == -1)break;

    visited[vv] = true;
    for(int i = 0 ; i < n ; i++ ){
      v[i] = min(v[i],v[vv] + dd[vv][i]);
    }
  }
}

int main(){

  cin >> n >> m;
  n++;

  int a,b,c,d;
  char ch;
  init();
  for(int i = 0 ; i < m ; i++ ){
       cin >> a >> ch >> b >> ch >> c >> ch >> d;
    dd[a][b] = c;
    dd[b][a] = d;
  }
  int spos,gpos,mone,hasira;
  cin >> spos >> ch >> gpos >> ch >> mone >> ch >> hasira;
  dijkstra(spos);
  int go,back; 
  go = v[gpos];

  dijkstra(gpos);

  back = v[spos];
  cout << mone-(go+back+hasira) << endl;
  return 0;
}