#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n)for(int i=0;i<n;i++)

const ll INF = 1001001001;

int main(){
  int n; cin>>n;
  vector<int>a(n,0);
  int ans = 0;
  rep(i,n){
    if(i%3!=0 && i%5!=0){
      a[i]=i;
      ans+=a[i];
    }
  }
  cout<<ans<<endl;
}