#include<bits/stdc++.h>
using namespace std;
#define ll long long
int t,n,m;
ll ans;
int main()
{
	cin>>n;
	ll l=n/3,r=n/5,k=n/15;
	ans=(ll)(n+1)*n/2-(3+(l-1)*3+3)*l/2-(5+(r-1)*5+5)*r/2+(15+(k-1)*15+15)*k/2;
	cout<<ans; 
	return 0; 
}