#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000000;

int main(){
    int 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;
}