#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long N,result=0;
    cin >> N;
 
    for (long i = 1 ; i<=N; i++) {
        if (i%3!=0 && i%5!=0) {
            result += i;
        }
    }

    cout << result << endl;



  	return 0;
}