#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    fast;
    int n;
    int a[100001];
    long long int sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0||(i%3==0&&i%5==0))
        {
            continue;
        }
        else
            sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}
