#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>

using namespace std;

int main()
{
    long long n;
    cin >> n;
    long long ans = 0;
    for (long long i = 1;i <= n;i++){
        if (i%3 == 0 || i%5 == 0){
            ;
        }
        else {
            ans = ans + i;
        }
    }
    cout << ans << endl;
}
