import Foundation

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

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

main()
