#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000009
# define pi acos(-1)
# define fi first
# define se second
using namespace std;


signed main()
{
    gok
    int n;
    cin>>n;
    int p=15;
    int su=0;
    int ss = n*(n+1);
    ss/=2;
    for(int i=3;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
            su+=i;
    }

cout<<ss-su;









      return 0;
    }
