#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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(){
  ll n; cin >> n;

  vector<ll> s(n+1,0);
  rep(i, n){
    if (i % 3 == 0 || i % 5 == 0) {
      s[i+1] = s[i];
      continue;
    }
    s[i+1] = s[i] + i;
  }
  cout << s[n] << endl;
}
