import Foundation

let main: () = {
    let N = getInt()
    var ans = 0
    for n in 1...N {
        if !n.isMultiple(of: 3) && !n.isMultiple(of: 5) { ans += n }
    }
    print(ans)
}()

func getString() -> String { readLine()! }
func getInt() -> Int { Int(getString())! }
func getDouble() -> Double { Double(getString())! }

