#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N;
	cin >> N;
	ll ans = 0;
	for (int i = 1; i <= N; i++)
	{
		if (!(i%15 == 0 || i%3 == 0 || i%5 == 0))
			ans += i;
	}
	cout << ans << endl;
}

