#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

typedef long long ll;

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	bool contain = false;

	int N;
	ll sum = 0;

	scanf("%d", &N);
	
	for (int i = 1; i <= N; ++i)
	{
		if (i % 3 && i % 5) sum += i;
	}

	printf("%lld\n", sum);

	return 0;
}