fun readInt(): Int {
    val N: Int = readLine()!!.toInt()
    return N
}

fun readString(): String {
    val N: String = readLine()!!
    return N
}

fun solveB(): Long{
    val N: Int = readLine()!!.toInt()
    var An: Array<Int?> = arrayOfNulls(N)
    var ans: Long = 0
    for (i in An.indices) {
        val num: Int = (i + 1)
        if (num%3 == 0 || num%5 == 0 ){
            continue
        }
        ans += num
    }
    return ans
}

fun main() {
    // 20200421 A problem
    /*
    if (readString().contains('7')){
        println("Yes")
    } else {
        println("No")
    }
    */
    println(solveB())
}