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

int gcd(int a,int b) {return b==0? a:gcd(b,a%b);}


int main(){
    ll n,ans=0;
    cin>>n;

    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0) ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}

