#include<iostream>
using namespace std;
int main()
{
    int n,i;
    long long unsigned ans=0;
    cin>>n;
    for(i=1;i<=n;i++){
    if(i%3&&i%5)
        {
            ans+=i;
        }

    }
        cout<<ans<<endl;

    return 0;
}




