#include  <iostream>
#include  <algorithm>
#include  <cstddef>
#include  <string>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define lrep(i, n, m) for(int i = n; i < m; i++)

typedef long long ll;
const int MAX = INT_MAX;

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

	ll sum = 0;
	lrep(i, 1, n + 1) {
		if (i % 3 != 0 && i % 5 != 0)  sum += i;
	}
	cout << sum << endl;
}