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

int main(){
    //A
    /*
    int N;
    cin>>N;
    if(N/100==7||N/10%10==7||N%10==7){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    */
   //B
   int n;cin>>n;
   ll c=0;
   rep(i,1,n+1) {
       if(i%3!=0&&i%5!=0) c+=i;
   }
   cout<<c<<endl;
}