#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;



int main()
{
	int n;
	ll int sum = 0LL;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		if (i % 3 && i % 5) {
			sum += (ll int)i;
		}
	}

	printf("%lld", sum);

	return 0;
}