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

ll INF = 1e18;
ll MOD = 1e9+7;

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