#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	ll n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		int k = i + 1;
		a[i] = k;
		if (k % 3 == 0 || k % 5 == 0) {
			a[i] = 0;
		}
	}
	ll sum(0);
	rep(i, n) {
		sum += a[i];
	}
	cout << sum;
}