#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

void Main()
{
  ll N;
  cin >> N;
  ll sum = 0;
  rep(i,N+1) {
    if (i % 5 == 0 || i % 3 == 0);
    else sum += i;
  }
  cout << sum << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}