
// Problem : B - FizzBuzz Sum
// Contest : AtCoder - AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    long n;
    cin >> n;
    long long s = 0;
    for (long i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) s = s + i;
    }
    cout << s;
    
    return 0;
}
