#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
int n;
cin >> n;
vector<int> a(n);
ll ans = 0;
for(int i = 1;i < n;i++){
    if(i%3 == 0 || i%5 == 0){
        a.at(i) = 0;
    }else{
        a.at(i) = i;
    }
ans += a.at(i);
}
    cout << ans << endl;

return 0;

}
