#include <iostream>
#include <vector>
using namespace std;
int n_town, n_road;
vector<vector<int>> costs;

void fw(vector<vector<int>> &conn_mat)
{
	costs = vector<vector<int>>(n_town, vector<int>(n_town, -1));
	int i(0), j(0);
	for (auto dep : conn_mat)
	{
		j = 0;
		for (int cost : dep)
		{
			if (cost != -1)
			{
				costs[i][j] = cost;
			}
			j++;
		}
		i++;
	}
	for (int k = 0; k < n_town; k++)
	{
		for (int i = 0; i < n_town; i++)
		{
			for (int j = 0; j < n_town; j++)
			{
				if (costs[i][k] != -1 && costs[k][j] != -1) {
					if ((costs[i][j] > costs[i][k] + costs[k][j] && costs[i][j] != -1) || (costs[i][j] == -1))
						costs[i][j] = costs[i][k] + costs[k][j];
				}
			}
		}
	}
}

int main()
{
	char tmp;
	cin >> n_town >> n_road;
	vector<vector<int>> conn_mat(n_town, vector<int>(n_town, -1));
	while (n_road--)
	{
		int dep, dest, cost_go, cost_back;
		cin >> dep >> tmp >> dest >> tmp >> cost_go >> tmp >> cost_back;
		conn_mat[dep - 1][dest - 1] = cost_go;
		conn_mat[dest - 1][dep - 1] = cost_back;
	}
	fw(conn_mat);
	int dep, dest, budget, cost;
	cin >> dep >> tmp >> dest >> tmp >> budget >> tmp >> cost;
	cout << budget - cost - costs[dep - 1][dest - 1] - costs[dest - 1][dep - 1] << endl;
}
