#include <iostream>
typedef long long int ll;

int main(){
    ll N;
    std::cin >> N;
    ll sum=0;
    
    for(ll i=1;i<=N;++i){
        if(i%3==0||i%5==0){
            
        } else {
            sum+=i;
        }
    }
    std::cout << sum << std::endl;
    return 0;
}