#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    long long ret = 0;
    for(int i=0; i<N; ++i) {
        if(i %3 == 0 || i % 5 == 0) 
            continue;
//        cout << i << endl;
        ret += i;
    }
    cout << ret << endl;

    return 0;
}
