#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll N;
	cin>>N;
	ll sum = (N+1)*N/2;
	ll a3 = N/3;
	ll a5 = N/5;
	ll a15 = N/15;
	sum -= 3*(a3+1)*a3/2;
	sum -= 5*(a5+1)*a5/2;
	sum += 15*(a15+1)*a15/2;
	
	cout << sum << endl;
}
