// B - FizzBuzz Sum
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	long long n;
	cin >> n;
	long long a = n / 3, b = n / 5, c = n / 3 / 5;
	long long ans = (1 + n) * n / 2 - 3 * (1 + a) * a / 2 - 5 * (1 + b) * b / 2 + 15 * (1 + c) * c / 2;
	cout << ans << endl;

	return 0;
}
