count :: [Integer] -> Integer
count [a, b] = 
    let sumInt :: Integer -> Integer
        sumInt n = (n * (n + 1)) `div` 2
        loop :: Integer -> Integer 
        loop 1000 = 0
        loop n = if ((sumInt n) - a /= 0 && (((sumInt n) - a) == ((sumInt (n + 1)) - b))) then (sumInt n) - a else loop $ n + 1
        in loop 0
main = print =<< (count . (map (\a -> read a :: Integer)) . words) <$> getLine
