#include <iostream>
#include <string>
using namespace std;
int main ()
{
	long long n,temp;
	cin>>n;
	long long three=(n/3);
	long long five=(n/5);
	long long fifteen=(n/15);
	long long a=(1+n)*n/2;
	long long b=(3+three*3)*three/2;
	long long c=(5+five*5)*five/2;
	long long d=(15+fifteen*15)*fifteen/2;
	cout<<a-b-c+d<<endl;
	
	
}