import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextLong()

  var x = 0L
  for (i <- 1L to N) {
    if (!(i % 3 == 0 || i % 5 == 0)) {
      x += i
    }
  }

  println(x)
}
