#include <iostream>

using namespace std;

#define ll long long int

int main()
{
	int n;
	cin >> n;
	ll sum = 0;
	while(n--) {
		int x = n + 1;
		if(x % 3 == 0 || x % 5 == 0) continue;
		sum += x;
	}
	cout << sum;
	return 0;
}
