#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int n, m, i1, i2, i3, i4;
typedef pair<int, int>P;
vector<P>v[34];
int dijkstra(int p, int key) {
	priority_queue<P, vector<P>, greater<P>>pq;
	pq.push(make_pair(0, p));
	int a[123456]; for (int i = 0; i < 123456; i++)a[i] = -1;
	while (pq.size()) {
		P p1 = pq.top(); pq.pop();
		if (p1.second == key)return p1.first;
		if (a[p1.second] == -1) {
			a[p1.second] = p1.first;
			for (P i : v[p1.second])
				if (a[i.first] == -1)pq.push(make_pair(p1.first + i.second, i.first));
		}
	}
}
int input() {
	string s; cin >> s;
	s += ',';
	int cnt = 0, k = 0;
	for (char ch : s) {
		if (ch == ',') {
			if (cnt == 0)i1 = k;
			if (cnt == 1)i2 = k;
			if (cnt == 2)i3 = k;
			if (cnt == 3)i4 = k;
			k = 0; cnt++;
		}
		else {
			k *= 10; k += ch - '0';
		}
	}
}
signed main() {
	cin >> n >> m;
	for1(i, m) {
		input();
		v[i1].push_back(mp(i2, i3));
		v[i2].push_back(mp(i1, i4));
	}
	input();
	cout << i3 - i4 - dijkstra(i1, i2) - dijkstra(i2, i1) << "\n";
}
