fun main(arg: Array<String>) {
    val N = nextLong()
    var total = N * (N + 1) / 2
    for (n in 3 .. N)
        if (n % 3 == 0L || n % 5 == 0L) total -= n
    return println(total)
}


fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
