object Main extends App {
    val n = scala.io.StdIn.readInt
    var output: Long = 0
    for(count <- 1 to n){
        if(count % 3 != 0 && count % 5 != 0) output += count
    }
    println(output)
}