#include <iostream>

using namespace std;
unsigned long long res=0;
long long n;

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