main :: IO ()
main = do
    [n, a, b] <- map read . words <$> getLine
    print $ (\(a, b) -> 10 * a + b) $ foldl1
        (\(a, b) (c, d) -> (a + c, b + d))
        [ (x, y)
        | x <- [0 .. 9]
        , y <- [0 .. 9]
        , 10 * x + y <= n
        , a <= x + y
        , x + y <= b
        ]
