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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
constexpr int INF = 1e9;
//constexpr ll INF = 1LL << 62;
constexpr int mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  ll sum = 0;
  FOR(i, 1, N+1){
    if(i%3 != 0 && i% 5!=0){
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}
