#include<iostream>
using namespace std;
typedef long long int ll;
int main()
{
  ll n;
  cin>>n;
  ll sum = 0;
  while(n--)
  {
    if(n%3==0 || n%5==0)
    {
    continue;}
    else
      sum = sum + n;
  }
  cout<<sum;
  return 0;
}


