#include <iostream>
using namespace std;

int main()
{
  long long n, i, sum;
  cin >> n;
  i = 0;
  sum = 0;
  while(i < n)
  {
    i++;
    if(i % 3 == 0 && i % 5 == 0)
      continue;
    else if(i % 3 == 0)
      continue;
    else if(i % 5 == 0)
      continue;
    else
      sum += i;
  }
  cout << sum;
  return 0;
}