#include <iostream>
using namespace std;
typedef long long ll;
ll n,ans;
int main(void){
    cin>>n;
    for(ll i=1LL;i<=n;i++){
        if(i%5==0||i%3==0)continue;
        else ans+=i;
    }
    cout<<ans<<endl;
}
