#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read()
{
    char ch=getchar();
    ll x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}


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