import Control.Applicative
import Control.Monad
import Data.List.Split (splitOn)

data LDGraph a c = LDG { p :: [a]
                       , v :: [((a,a),c)]
                       } deriving Show

main = do
  n <- readLn
  m <- readLn
  roads <- replicateM m getRoad
  [start,goal,value,price] <- map read.splitOn ","<$>getLine
  let graph = toGraph [1..n] roads
      Just min = (+)<$>minMoney graph [] start goal<*>minMoney graph [] goal start
  print $ value - price - min

getRoad :: IO (Int,Int,Int,Int)
getRoad = do
  [a,b,c,d] <- map read.splitOn ","<$>getLine
  return (a,b,c,d)

toGraph :: [Int] -> [(Int,Int,Int,Int)] -> LDGraph Int Int
toGraph ps xs = LDG ps vs
  where vs = toVecs xs

toVecs :: [(Int,Int,Int,Int)] -> [((Int,Int),Int)]
toVecs = foldr (\x -> (func x ++)) []
  where func (a,b,c,d) = [((a,b),c),((b,a),d)]

label :: Eq a => LDGraph a c -> a -> a -> Maybe c
label g a b = if null vect then Nothing
                           else Just $ snd.head $ vect
  where vect = filter (\x -> fst x == (a,b)) $ v g

minMoney :: (Eq a) => LDGraph a Int -> [a] -> a -> a -> Maybe Int
minMoney g h a b 
  | a == b = Just 0
  | otherwise = minimum' $ [ (+)<$>label g a j<*>minMoney g (a:h) j b | j <- list]
  where list = map snd.filter (\(x,y) -> (x == a) && not (y `elem` h)).map fst $ v g
        minimum' = \x -> if null x then Just 0
                                   else minimum x

testData :: LDGraph Int Int
testData = LDG [1..6] [((1,2),2),((1,3),4),((1,4),4),((2,1),2),((2,5),3),((3,1),3),((3,4),4),((3,6),1),((4,1),2),((4,3),2),((4,6),2),((5,2),2),((5,6),1),((6,3),2),((6,4),1),((6,5),2)]