#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7


int main(){
    int n;
    cin >> n;
    LL ans = 0;

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

    cout << ans << endl;

    return 0;
}