#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    long long int n,m,a,b,ans=0,temp;
    string s;
    cin>>n;
    for(int i = 1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
            ans+=i;
    }
    
    
    cout<<ans<<endl;
    return 0;
}
