#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;



int main() {
    ll n, sum = 0;
    
    cin>>n;
    
    rep(i, n+1){
        if(i%3==0 || i%5==0) sum+=0;
        else sum+= i;
    }
    
    cout<<sum<<endl;
    return 0;
}
