main :: IO ()
main = do
  n <- read <$> getLine :: IO Integer
  let a = f (n `div` 3) * 3
      b = f (n `div` 5) * 5
      c = f (n `div` 15) * 15
      f x = (1 + x) * x `div` 2
  putStrLn $ show $ (f n) - a - b + c
