#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <string>
#include <unordered_map>
using namespace std;


int main() {

    long N;
    cin >> N;

    long sum;

    for(int i = 1; i <= N; i++){
        if(i%3 == 0) {
            continue;
        }
        if(i%5 == 0) {
            continue;
        }
        sum += i;
    }

    cout << sum << endl;
    return 0;
}
