#include <iostream>
#include <unordered_map>
#include <iterator>
#include <algorithm>
#include <string>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
const int64_t BIG_PRIME = 1000000007;


int main(){
    int n;
    cin >> n;
    int64_t sum=0;
    for(int i=1; i<=n; i++){
        if(i%3==0 || i%5==0){

        }else{
            sum += i;
        }
    }

    cout << sum << endl;
}