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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

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