#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

int main(){
    int n;
    cin >> n;
    long long ans = 0;
    rep(i,1,n+1){
        if(i%3 != 0 && i%5 != 0 ){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}