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

void Main()
{
    long n;
    long s = 0;
    cin >> n;
    for(long i=1;i<=n;++i){
        if(!(i % 3 == 0 || i % 5 == 0)){
            s += i;
        }
    }
    cout << s << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}
