#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

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