#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

bool kaibun(string s){
    size_t len = s.length();
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1]) return false;
    }
    return true;
}

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

    return 0;
}