def set edge, data
  edge[data[0] - 1] << [data[1] - 1, data[2]]
  edge[data[1] - 1] << [data[0] - 1, data[3]]
  edge
end

White = -1
Gray = 0
Black = 1
Max = 100000
def bfs edge, s
  dist = Array.new(edge.size).fill(Max)
  color = Array.new(edge.size).fill(White)
  color[s] = Gray
  dist[s] = 0
  q = Queue.new
  q.push s

  while !(q.empty?) do
    from = q.pop
    edge[from].each do |e|
      to = e[0]
      cost = e[1]
      dist[to] = ((total = dist[from] + cost) < dist[to])? total : dist[to]
      if color[to] == White
        color[to] = Gray
        q.push to
      end
    end
    color[from] = Black
  end
  dist
end

edge = Array.new($stdin.gets.to_i).map{Array.new}
$stdin.gets.to_i.times do
  edge = set edge, $stdin.gets.chomp.split(",").map(&:to_i)
end
start, dest, money, price = $stdin.gets.chomp.split(",").map(&:to_i)

p (money - price - bfs(edge, start - 1)[dest - 1] - bfs(edge, dest - 1)[start - 1])