main = do
  li <- getLine
  let n = read li
  let ans = compute n
  print ans

{-
nまでの数の和はs=n(n+1)/2
3の倍数は数えない、a=n/3個、和はt=a(a+1)/2*3
5の倍数も数えない、b=n/5個、和はu=b(b+1)/2*5
s-t-uだと15の倍数を引きすぎる
15の倍数がc=n/15個、総和はv=c(c+1)/2*15
戻すとs-t-u+v
-}

compute :: Int -> Int
compute n = f n - 3 * f (div n 3) - 5 * f (div n 5) + 15 * f (div n 15)
  where
    f k = div (k * (k + 1)) 2
