#include <iostream>
using namespace std;

#define int long long

signed main()
{
    int i=0, j=0, ans=0;
    int n;
    cin>>n;

    for(i;i<n;i++){
        if((i%3)&&(i%5)){
            ans+=i;
        }
    }

    cout<<ans<<endl;
    return 0;
}