#include <iostream>
#include <algorithm>
#include <sstream>
using namespace std;

const int MAXN = 21;
const int INF = 1<<28;
int N;
int G[MAXN][MAXN];

int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      G[i][j] = i == j ? 0 : INF;
    }
  }
  int m;
  cin >> m;
  ++m;
  int a, b, c, d;
  while(m--) {
    string s;
    cin >> s;
    replace(s.begin(), s.end(), ',', ' ');
    stringstream ss(s);
    ss >> a >> b >> c >> d;
    --a;
    --b;
    if(!m) break;
    G[a][b] = c;
    G[b][a] = d;
  }

  for(int k = 0; k < N; ++k) {
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < N; ++j) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }

  cout << c-d-G[a][b]-G[b][a] << endl;
  return 0;
}