import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextLong()
    var total = 0L
    for (i in 1 .. N) {
        if (i % 3 == 0L || i % 5 == 0L) {
            continue
        }
        total += i
    }
    println(total)
}
