#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    ll i=1;
    ll sum=0;
   while(i<=n)
   {
       if(i%3!=0&&i%5!=0)
       {
           sum+=i;
          // cout<<i<<" ";
       }
       i++;


   }
   cout<<sum<<endl;

}
