#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL ans;
int main(){
    LL n;
    cin>>n;
    for(LL i = 1;i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0)ans += i;
    }
    cout<<ans<<endl;
    return 0;
}
