#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
int main() {
	int N;
	ll s = 0;
	scanf("%d", &N);
	rep(i, 1, N + 1) {
		if (i % 3 && i % 5)s += i;
	}
	printf("%lld\n", s);
	return 0;
}
