#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;


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