#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>

using namespace std;

const int CONSUMPTION_TAX = 0.1;

int main()
{
  int64_t N;

  cin >> N;

  int64_t sum = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }

  cout << sum << endl;

  return 0;
}
