/**********************************************************************************************************
***********************************************************************************************************
**********************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
/**************************************Define basic function start here***********************************/
ll GCD(ll a, ll b){ll gcd, g;g = __gcd(a, b);return g;}
ll LCM(ll a, ll b){ll gcd, g;g = __gcd(a, b);return (a/g)*b;}
/**********************************************Define basic function end here******************************/
const ll INF_LONG = 1LL<<61;
const unsigned int inf_int = 1<<31;
const ll mod = 1e9+7;
double phi = acos(-1);
/**********************************************************************************************************/

/***********************************************************************************************************/
int main()
{
    long double sum = 0;
   int n;
   cin >> n;
   if(n %2 == 0)
   {
       sum = (n/2);
       sum *= (n+1);
   }
   else
   {
       sum = ((n+1)/2);
       sum *= n;
   }
   for(int i = 1; i <= n; i++)
   {
       if(i % 3 == 0 && i % 5 == 0)
       {
           sum -= i;
       }
       else if(i % 3 == 0)
       {
           sum -= i;
       }
       else if(i % 5 == 0)
       {
           sum -= i;
       }
   }
   cout << sum << endl;
    return 0;
}
