
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	long long  n;
	cin >> n;
	long long sum = n * (n + 1) / 2;
	for (long long  int i = 1; 3 * i <= n; i++) {
		if((3*i)%15!=0)
		sum -= 3 * i;

	}
	for (long long int i = 1; 5 * i <= n; i++) {
		if ((5* i) % 15 != 0)
		sum -= 5 * i;
	}
	for (long long int i = 1; 15 * i <= n; i++) {
		sum -= 15 * i;
	}
	cout << sum << endl;
}