#include <bits/stdc++.h>
using namespace std;

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