fun main(args: Array<String>) {
    val line: String = readLine()!!.trim()
    val n: Long = line.toLong()
    var result: Long = 0

    for (i: Long in (1..n)) {
        if (i % 3L != 0L && i % 5L != 0L) {
            result += i
        }
    }

    println("${result}")
}
