#include<bits/stdc++.h>
#define MAX INT_MAX
#define F first
#define S second
using namespace std;
vector<int> town[2000];
vector<int> cost[2000];
typedef pair<int,int> P;
int main(void)
{
	int n,m;
	int a,b,c,d;
	int s,g,v,p;
	char ch,ch1,ch2,ch3;
	
	int flg[2000];
	int length[2000];
	int x,y;
	P pp;
	priority_queue<P,vector<P>,greater<P>> que;
	
	int i;
	cin>>n>>m;
	
	for(i=0;i<m;i++){
		cin>>a>>ch>>b>>ch1>>c>>ch2>>d;
		
		town[a].push_back(b);
		cost[a].push_back(c);
		
		town[b].push_back(a);
		cost[b].push_back(d);
		
	}
	
	cin>>s>>ch>>g>>ch>>v>>ch>>p;
	
	fill(length,length+(n+1),MAX);
	fill(flg,flg+(n+1),0);
	
	que.push(P(0,s));

	while(que.size()!=0){
		pp=que.top();
		que.pop();
		x=pp.F;
		y=pp.S;
		if(x<length[y]){
			length[y]=x;
			flg[y]=1;
			for(i=0;i<town[y].size();i++){
				if(flg[town[y][i]]==0){
					que.push(P(x+cost[y][i],town[y][i]));
				}
			}
		}
	}
		
	while(!que.empty()){
		que.pop();
	}
	int wk;
	wk=length[g];
//	cout<<wk<<endl;
	
	fill(length,length+(n+1),MAX);
	fill(flg,flg+(n+1),0);
	
	que.push(P(0,g));

	while(que.size()!=0){
		pp=que.top();
		que.pop();
		x=pp.F;
		y=pp.S;
		if(x<length[y]){
			length[y]=x;
			flg[y]=1;
			for(i=0;i<town[y].size();i++){
				if(flg[town[y][i]]==0){
					que.push(P(x+cost[y][i],town[y][i]));
				}
			}
		}
	}
	
	int wk1;
	wk1=length[s];
	//cout<<wk1<<endl;
	
	cout<<v-p-wk-wk1<<endl;
	return 0;
}
	
