#include <bits/stdc++.h>

using namespace std;

typedef long long	ll;

int main(){
	ll n;

	scanf("%lld", &n);

	ll sum = 0LL;

	for(ll i = 1LL ; i <= n ; i++){
		if(i % 3LL ==0LL || i % 5LL == 0LL) continue;

		sum += i;
	}

	cout << sum << endl;

	return 0;
}