import Foundation

func readInts() -> [Int]{
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let n = Int(readLine()!)!
    var ans = 0
    
    for i in 1...n {
        if i % 3 != 0 && i % 5 != 0 {
            ans += i
        }
    }
    print(ans)
}

main()
