#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll N、S;
  cin>>N;
  S=(N*(N+1))/2;
  rep(i,3,N+1) {
    if(i%3==0 || i%5==0)
      S-=i;
  }
  cout<<S<<endl;
}
