#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int n,m,start,end,money,price;
struct edge{int to,cost;};
vector<edge> g[30];
int d[30];
void dijkstra(int s)
{
	fill(d,d+n,INF);
	d[s]=0;
	priority_queue<P,vector<P>,greater<P> > q;
	q.push(mp(0,s));
	while(!q.empty())
	{
		P a=q.top();
		q.pop();
		int v=a.sec;
		if(d[v]<a.fi)continue;
		for(int i=0;i<g[v].size();i++)
		{
			edge e=g[v][i];
			if(d[e.to]>d[v]+e.cost)
			{
				d[e.to]=d[v]+e.cost;
				q.push(mp(d[e.to],e.to));
			}
		}
	}
	return;
}
int main()
{
	cin >> n;
	cin >> m;
	for(int i=0;i<m;i++)
	{
		int a,b,c,d;
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		a--;b--;
		edge in;
		in.to=b;in.cost=c;
		g[a].pb(in);
		in.to=a;in.cost=d;
		g[b].pb(in);
	}
	scanf("%d,%d,%d,%d",&start,&end,&money,&price);
	start--;end--;
	money-=price;
	dijkstra(start);
	money-=d[end];
	dijkstra(end);
	money-=d[start];
	cout << money << endl;
	return 0;
}