#include <bits/stdc++.h>

using namespace std;

int a = 1;

int main()
{
    int num;
    long long result = 0;
    cin >> num;
    for(int i = 1;i <= num;i++){
        if(i % 3 == 0 || i % 5 == 0){
            continue;
        }
        result += i;
    }
    cout << result << endl;
    return 0;
}