#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long int N;
    cin >> N;
    long int sum = 0;
    for(int i=1; i<=N; i++){
        if(i%3!=0 && i%5!=0)
            sum+=i;
    }
    cout << sum;
    
}