#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define MAXN 2000000
#define int long long
#define INF (1e9 + 7)
#define MANX MAXN
// #pragma GCC optimize(2)

using namespace std;

inline int read()
{
	int x = 0, f = 1; char c = getchar();
	while (c > '9' || c < '0') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') {x = x * 10 + (c ^ 48); c = getchar();}
	return f * x;
}

int n, ans;

signed main()
{
	n = read();
	for (int i = 1; i <= n; i++)
		if (i % 3 != 0 && i % 5 != 0)
			ans += i;
	cout << ans;
	return 0;
}