fun main() {
    println(solve())
}

val solve: () -> Any = {
    (1L..readLong()).filter { it % 3L != 0L && it % 5L != 0L }.sum()
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()