//https://atcoder.jp/contests/abc162/tasks/abc162_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll N;cin>>N;
  ll ans=0;
  FOR(i,1,N+1){
    if(i%3==0||i%5==0){

    }else{
      ans += i;
    }
  }
  cout<<ans<<endl;
  return 0;
}