import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()

  println(abc162b(n))
}

private fun abc162b(n: Long): Long {
  val ans = (1L..n).map { it }.filter { it % 3L != 0L && it % 5L != 0L }.sum()

  return ans
}
