#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const ll mod=1e9+7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll s=0;
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0) s+=i;
    }
    cout<<s<<endl;
    return 0;
}
