#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int N;
	LL sum = 0;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		if ((i % 3 != 0) && (i % 5 != 0)) sum += i;
	}
	printf("%lld\n", sum);
}