#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m,l;
//ll dp[15][1005];
void solve()
{   
  
string s;
cin>>n;
ll ans=0;
for(ll i=1;i<=n;i++)
{
    if(i%3!=0 && i%5!=0) ans+=i;
}
cout<<ans;




}    
int main()
{  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //cout<<primes.size();
    ll t=1;
    //cin>>t;
    while(t--)
        solve();

}
