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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e8) + 5;
const int MAX_A = int(15e6);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
string dir = "RDLU";
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

struct edge{
    int to, cost;
};

int n, m;
int s, g, vv, pp;
int dmin[25];
vector<edge> G[25];

void dijkstra(){
    fill(dmin,dmin+n,IINF);
    dmin[s] = 0;
    priority_queue<P,vector<P>,greater<P> > que;
    que.push(P(0,s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        if(p.first > dmin[p.second])continue;
        int v = p.second;
        for(auto e : G[v]){
            if(dmin[e.to] > dmin[v] + e.cost){
                dmin[e.to] = dmin[v] + e.cost;
                que.push(P(dmin[e.to],e.to));
            }
        }
    }
}



int main() {
    cin >> n >> m;
    REP(i,m+1){
        string ss;
        cin >> ss;
        vector<int> ls;
        int bg = 0;
        while(ss.find(',', bg) != ss.npos){
            bg = ss.find(',', bg);
            ls.push_back(bg);
            bg++;
        }
        int a, b, c, d;
        a = stoi(ss.substr(0,ls[0]));
        b = stoi(ss.substr(ls[0]+1,ls[1]-ls[0]));
        c = stoi(ss.substr(ls[1]+1,ls[2]-ls[1]));
        d = stoi(ss.substr(ls[2]+1,ss.size()-ls[2]));

        a--;
        b--;
        if(i<m){
            G[a].push_back({b,c});
            G[b].push_back({a,d});
        }
        else{
            s = a;
            g = b;
            vv = c;
            pp = d;
        }
    }
    int ans = pp;
    dijkstra();
    ans += dmin[g];
    swap(s,g);
    dijkstra();
    ans += dmin[g];
    cout << vv - ans << endl;

    return 0;
}

