import Data.List

main = print $ fst $  max' [ (n,d) | d <- [1..1000000], n <- [3*d `div` 7 .. d `div` 2], gcd d n == 1, toFloat (n,d) < toFloat (3,7) ]

toFloat :: (Int, Int) -> Float
toFloat (a,b) = (fromIntegral a) / (fromIntegral b)

max' :: [(Int, Int)] -> (Int, Int)
max' [x] = x
max' [(a,b),(c,d)] = if a*d > c*b then (a,b) else (c,d)
max' (x:xs:xss) = max' $ max' (x:[xs]) : xss
