#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

const int INF = 10000;

void p(vector<int> v){
	for(int i = 0; i < v.size(); i++){
//		cout << v[i] << ' ';
		printf("%6d", v[i]);
	}
	cout << endl;
}

void p(vector<vector<int> > v){
	for(int i = 0; i < v.size(); i++){
		p(v[i]);
	}
}

int main(){
	int n, m;

	cin >> n >> m;

	vector<vector<int> > road(++n);
	for(int i = 0; i < n; i++){
		road[i].resize(n, INF);
	}

	for(int i = 0; i < m; i++){
		int a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		road[a][b] = c;
		road[b][a] = d;
	}

	for(int i = 1; i < n; i++){
		for(int j = 1; j < n; j++){
			for(int k = 1; k < n; k++){
				road[j][k] = min(road[j][k], road[j][i] + road[i][k]);
			}
		}
	}

//	p(road);

	int x1, x2, y1, y2;
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);

	int reward = y1 - (y2 + road[x1][x2] + road[x2][x1]);

	cout << reward << endl;

	return 0;
}