#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
typedef long long  ll;
typedef long double lb;
using namespace std;
int main() {
	int n;
	cin >> n;
	int a = 0;
	for (int i = 1; i <= n; i++) {
		if ((i % 3 != 0) && (i % 5 != 0)) {
			a += i;
		}
	}
	cout << a;
}
