#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>

using namespace std;

#define ll long long
#define rep(i, n) for (i = 0; i < n; i++)

int main()
{
  int N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; i++)
  {
    if (i % 3 == 0 || i % 5 == 0)
    {
      continue;
    }
    else
    {
      ans += i;
    }
  }
  cout << ans << endl;
}
