object Main extends App {
  val n =  scala.io.StdIn.readInt()
  var result = 0L

  (1 to n).foreach { i =>
    if (i % 3 != 0 && i % 5!= 0) {
      result = result + i.toLong
    }
  }

  println(result)

}