#include<iostream>
using namespace std;

long long sum(long long x){
    if(x == 0){
        return 0;
    }
    else if((x%3 == 0)||(x%5 == 0)){
        return sum(x - 1);
    }
    else{
        return x + sum(x - 1);
    }
}

int main(){
    long long n;
    cin >> n;
    cout << sum(n) << endl;
    return 0;
}