fun main(args: Array<String>) {
  var tmp = readLine()!!.split(" ").map(String::toLong)
  val n = tmp[0]
  val allSum = n * (n + 1L) / 2L
  val count3 = n / 3L
  val count5 = n / 5L
  val count15 = n / 15L
  val sum3 = (3L + (n - (n % 3L))) * count3 / 2L
  val sum5 = (5L + (n - (n % 5L))) * count5 / 2L
  val sum15 = (15L + (n - (n % 15L))) * count15 / 2L
  println(allSum - (sum3 + sum5 - sum15));
}
