#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true; } return false; }


int main() {
  int N;
  cin >> N;

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

  cout << sum << endl;
}
