import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt

    def s(i: Int): Long = {
      i * (i + 1L) / 2
    }

    out.println(s(n) - s(n / 3) * 3 - s(n / 5) * 5 + s(n / 15) * 15)

    out.flush()
  }
}
