#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io
    
    int n;
    cin>>n;

    ll sum=0;
    for(int i=1;i<=n;i++){
        if(i%3==0 || i%5==0 || i%15==0){
            continue;
        }
        sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}