#include <bits/stdc++.h>
 
using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP(x)	make_pair(x)
 
#define debug(_x)		cerr << #_x << '=' << _x << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << _x << ' ' << #_y << '=' << _y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;
 
const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;

int32_t main() {
	FAST_IO;
	
	int n;
	cin >> n;
	
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i%3 == 0 || i%5 == 0) {
		
		} else {
			ans += i;
		}
	}
	cout << ans << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined

