#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
using namespace std;

ll n, ans;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read();
	ans = (1 + n) * n >> 1;
	REP(i, 3, n)
		if (i % 3 == 0 || i % 5 == 0) ans -= i;
	printf("%lld\n", ans);
}

int main(){
	work();
	return 0;
}