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

int main()
{
	int N;
	cin >> N;

	long long ans = 0;
	for( int x = 1; x <= N; x++ ) {
		if( x % 3 == 0 || x % 5 == 0 ) continue;
		ans += x;
	}

	cout << ans << endl;
}
