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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int N;
    cin >> N;

    lint ans = 0;
    for_(i,1,N+1) {
        if (i % 3 != 0 and i % 5 != 0) ans += i;
    }
    cout << ans << endl;
}