#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    
    ll r = 0;

    int cnt = 1;
    while (cnt <= n) {
        if (cnt % 3 != 0 && cnt % 5 != 0) {
            r += cnt;
        }
        ++cnt;
    }

    cout << r << endl;

    return 0;
}