#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
void f(int a[][21],int b[],int c,int e,int m){
  int i;
  if(c==e){
    if(b[c]==-1||b[c]>m)
      b[c]=m;
  }else if(b[c]==-1||b[c]>m){
    b[c]=m;
    for(i=1;i<21;i++){
      if(a[c][i])
	f(a,b,i,e,m+a[c][i]);
    }
  }
  return;
}
int main(){
  int i;
  int a[21][21],b[21],m,n,v,w,x,y;
  memset(a,0,sizeof(a));
  cin>>n>>m;
  for(i=0;i<m;i++){
    int p,q,r,s;
    scanf("%d,%d,%d,%d",&p,&q,&r,&s);
    a[p][q]=r;
    a[q][p]=s;
  }
  scanf("%d,%d,%d,%d",&v,&w,&x,&y);
  memset(b,-1,sizeof(b));
  f(a,b,v,w,0);
  x-=b[w];
  memset(b,-1,sizeof(b));
  f(a,b,w,v,0);
  x-=b[v];
  cout<<(x-y>0?x-y:0)<<endl;
  return 0;
}