function Main(n) {
    let arr = [];
    for (var i=n;i>0;i--) {
        if(i % 15 === 0 || i % 5 === 0 || i % 3 === 0) {
            arr.unshift(0);
        } else {
            arr.unshift(i);
        }
    }
    let a = 0;
    for (var x=arr.length;x>0;x--) {
    a = a + arr[x-1];
    }
    console.log(a);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));