#include<bits/stdc++.h>
#define rep(i, n) for (int i =1; i <= (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  ll n,sum=0;cin>>n;
  rep(i,n){
    if(i%3!=0&&i%5!=0)sum+=i;
  }
  cout<<sum;
  

}