#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
 
int main(){
    unsigned long long N;
    cin >> N;
    unsigned long long sum=0;
    rep(i, N){
        if((i+1)%3!=0&&(i+1)%5!=0){
            sum += i+1;
        }
    }
    cout << sum << endl;

    return 0;
}