#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    int n;
    cin >> n;

    ll ans = 0;

    for(int i = 1;i <= n;i++){
        if(i % 15 == 0){}
        else if(i % 3 == 0){}
        else if(i % 5 == 0){}
        else ans += i;
    }

    cout << ans << endl;

    return 0;
}