import scala.io.StdIn._
object Main extends App{
  val N = readLine().toInt

  var sum = 0L
  (1 to N).foreach(i =>{
    if(i % 3 == 0 || i % 5 == 0){
    }else{
      sum = sum + i
    }
  })
  println(sum)
}
