#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;

long long msum(long long x){
  if(x<1) return 0;
  else return x*(x+1)/2;
}

int main() {
  long long n;
  cin>>n;
  int nf=n/3,nb=n/5,nfb=n/15;
  long long ans=msum(n)-3*msum(nf)-5*msum(nb)+15*msum(nfb);
  cout<<ans<<endl;
}