#include <iostream>
#include <string>
#include <math.h>
#include <list>
using namespace std;

int main(){
    int N;
    long sum = 0;
    cin >> N;

    for(long i=0; i<N; i++){
        if(i%3!=0 && i%5!=0)
            sum += i;
    }

    cout << sum << endl;
}