object Main extends App {

  val n = scala.io.StdIn.readInt()

  def solve(): Long = {
    (1 to n).foldLeft(0L) { case (acc, num) =>
      if(num % 3 != 0 && num % 5 != 0) acc + num else acc
    }
  }
  println(solve)
}