#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


int main() {
	int n;
	long long int sum = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 5 == 0)continue;
		sum += i;
	}
	cout << sum << endl;

	return 0;
}

