#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF 1e9

struct Edge {
    int to, cost;
};

struct P {
    int town, cost;

    bool operator >(const P& p) const {
        return cost > p.cost;
    }
};

int G[21];

int main() {
    int town_n, road_n;
    cin >> town_n >> road_n;

    vector<vector<Edge>> E(town_n+1);
    REP(i, road_n) {
        int a, b, c, d;
        char delim;
        cin >> a >> delim >> b >> delim >> c >> delim >> d;
        E[a].push_back({b, c});
        E[b].push_back({a, d});
    }
    int start, goal, money, hashira;
    char delim;
    cin >> start >> delim >> goal >> delim >> money >> delim >> hashira;

    int cost1 = 0, cost2 = 0;

    fill_n((int *)G, 21, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({start, 0});
    G[start] = 0;
    while (!que.empty()) {
        P p = que.top(); que.pop();
        if (p.town == goal) {
            cost1 = p.cost;
            break;
        }
        for (Edge& e : E[p.town]) {
            int next_cost = p.cost + e.cost;
            if (G[e.to] > next_cost) {
                G[e.to] = next_cost;
                que.push({e.to, next_cost});
            }
        }
    }
    fill_n((int *)G, 21, INF);
    while (!que.empty()) que.pop();
    que.push({goal, 0});
    G[goal] = 0;
    while (!que.empty()) {
        P p = que.top(); que.pop();
        if (p.town == start) {
            cost2 = p.cost;
            break;
        }
        for (Edge& e : E[p.town]) {
            int next_cost = p.cost + e.cost;
            if (G[e.to] > next_cost) {
                G[e.to] = next_cost;
                que.push({e.to, next_cost});
            }
        }
    }
    cout << (money - hashira - cost1 - cost2) << endl;
}