fun main(args:Array<String>) {
    val n:Long = readLine()!!.toLong()
    var ans:Long = 0
    for (x in 1L..n) {
        if (x % 15L != 0L && x % 5L != 0L && x % 3L != 0L) {
            ans += x.toLong()
        }
    }
    println(ans)
}