#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <numeric>

using namespace std;


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