#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
 
int main() {

int n;cin>>n;
  ll a=0;
  for(int i=1;i<(n+1);i++){
    if(i%5!=0&&i%3!=0){a=a+i;}
  }
cout<<a<<endl;
}

