#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	long long N;
	cin >> N;

	long long sum = N * (N + 1) / 2;

	long long val3 = N / 3;
	long long sum3 = 3 * val3 * (val3 + 1) / 2;

	long long val5 = N / 5;
	long long sum5 = 5 * val5 * (val5 + 1) / 2;

	long long val15 = N / 15;
	long long sum15 = 15 * val15 * (val15 + 1) / 2;

	long long ans = sum - sum3 - sum5 + sum15;

	cout << ans << endl;

	return 0;
}

