#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

const int N = 1e6 + 10;
bool f[N];
int n;

int main() {
	cin >> n;
	for (int i = 3; i <= n; i += 3) f[i] = true;
	for (int i = 5; i <= n; i += 5) f[i] = true;

	long long res = 0;
	for (int i = 1; i <= n; i++)
		if (!f[i])
			res += i;

	cout << res << endl;

	return 0;
}