#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
    ll a;
    cin>>a;
    ll ans=0;
    for (int i = 0; i < a; ++i) {
        if(i%3!=0 && i%5!=0)ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}
