//#include <bits/stdc++.h>
#include<stdio.h>
//using namespace std;

typedef long long ll;
const long long mod = 1e9 + 7;
const long long maxn = 1e6 + 5;

int main()
{
	ll n, sum = 0;
	scanf("%lld",&n);
	for (ll i = 1; i <= n; i++)
	{
		if (i % 3 == 0 || i % 5 == 0)
		{
			continue;
		}
		else
		{
			sum += i;
		}
	}
	printf("%lld\n",sum);
	return 0;
}
 
