#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
//#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


int main()
{
	int n;
	scanf("%d", &n);
	long long sum = 0;
	for (int i = 1 ; i <= n ; i++) {
		if (i % 3 == 0)
			continue;
		if (i % 5 == 0)
			continue;
			
		sum = sum + i;
	}
	
	printf("%lld\n", sum);
	
	
	return 0;
}