// J4180449 三宅亮輔
// 問題名
// - A Reward For A Carpenter
// 問題URL
// - https://onlinejudge.u-aizu.ac.jp/problems/0117
// 所要時間
// -
// 学んだこと
//
//
//

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll n;

ll m;

ll a[101], b[101], c[101], d[101];

ll s, g, V, P;

ll D[21][21];

const ll INF = 0xfffffff;
vector<ll> v;

string S;

int main() {
    cin >> n >> m;
    for(ll i = 0; i < n; i++)
        for(ll j = 0; j < n; j++)
            D[i][j] = INF;

    for(ll i = 0; i < n + 1; i++)
        D[i][i] = 0;

    for(ll i = 0; i < m + 1; i++) {
        v.clear();
        cin >> S;
        for(ll j = 0; j < S.size(); j++) {
            if(S[j] == ',')
                v.push_back(j);
        }
        ll a, b, c, d;
        a = stoi(S.substr(0, v[0]));
        b = stoi(S.substr(v[0] + 1, v[1] - v[0] - 1));
        c = stoi(S.substr(v[1] + 1, v[2] - v[1] - 1));
        d = stoi(S.substr(v[2] + 1, v.size() - v[2] - 1));
        a--;
        b--;
        if(i < m) {
            D[a][b] = c;
            D[b][a] = d;
        } else {
            s = a;
            g = b;
            V = c;
            P = d;
        }
    }

    for(ll k = 0; k < n; k++)
        for(ll i = 0; i < n; i++)
            for(ll j = 0; j < n; j++)
                D[i][j] = min(D[i][j], D[i][k] + D[k][j]);

    cout << V - P - (D[s][g] + D[g][s]) << endl;
}
