#include<bits/stdc++.h>

// macros
#define M 1000000007
#define addmod(a,b,m) (a%m + b%m)%m
#define submod(a,b,m) (a%m - b%m)%m
#define mulmod(a,b,m) ((a%m)*(b%m))%m
#define F first
#define S second
#define APSUM(a,b,n) n*((a*.5)+(b*.5))
#define GPSUM(a,b,k) (b*k-a)/(k-1)
#define INFGP(a,k) a/(1-r)
#define CEIL(a,b) ceil(double(a)/double(b))
#define FLOOR(a,b) floor(double(a)/double(b))
#define T(t) while(t--)
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

//typedefs
typedef long long int ll ;
typedef vector<ll> vi ;
typedef pair<ll,ll> pi ;
typedef map<ll,ll> mps;

ll power(ll base,ll val)
{
    ll res=1;
    while(val)
    {
        if(val&1)
    {
        res = (res*base)%M;
    }
     base = (base*base)%M;
     val/=2;
    }
    return res;
}
ll digit(ll n)
{
    double phi = (1 + sqrt(5))/2;
    ll value = round(pow(phi,n)/(sqrt(5)));
    ll count=0;
    while(value)
    {
        count++;
        value/=10;
    }
    return count;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
/*
when files are giving the inputs and outputs
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);

*/
    ll n;
    cin>>n;
    ll sum=0;
   for(int i=1;i<n;i++)
   {
       if(i%3!=0&&i%5!=0)
       {
           sum+=i;
       }
   }
    cout<<sum<<endl;
}
