#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
	int n, m;
	int x1, x2, y1, y2;
	char dummy;

	cin >> n;
	cin >> m;

	vector<int> a(m), b(m), c(m), d(m);
	vector< vector <int> > map(n + 1, vector<int>(n + 1, INT_MAX / 4));
	
	for(int i = 0; i < m; i++) {
		cin >> a[i] >> dummy >> b[i] >> dummy >> c[i] >> dummy >> d[i];
	}
	cin >> x1 >> dummy >> x2 >> dummy >> y1 >> dummy >> y2;

	for(int i = 0; i < m; i++) {
		map[a[i]][b[i]] = c[i];
		map[b[i]][a[i]] = d[i];
	}
	for(int i = 0; i < n; i++) {
		map[i][i] = 0;
	}

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

	y1 -= map[x1][x2] + map[x2][x1] + y2;

	cout << y1 << endl;

	return 0;
}