#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N;
    ll ans = 0;
    cin >> N;
    for(int i=1;i<=N;i++){
        if(!(i%3==0||i%5==0)){
            ans+=i;
        }
    }
    cout << ans << endl;
    return 0;
}