#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	int n_t3 = n / 3;
	int n_t5 = n / 5;
	int n_t15 = n / 15;
	long long s_t3 = (3 + 3 + (n_t3 - 1) * 3) * 1LL * n_t3 / 2;
	long long s_t5 = (5 + 5 + (n_t5 - 1) * 5) * 1LL * n_t5 / 2;
	long long s_t15 = (15 + 15 + (n_t15 - 1) * 15) * 1LL * n_t15 / 2;
	long long tmp = (1 + n) * 1LL * n / 2;
	long long ans = tmp - s_t3 - s_t5 + s_t15;
	cout << ans << E;
	//system("pause");
	return 0;
}