#include <iostream>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ULL unsigned long long
#define LL long long

using namespace std;

int main(){
	ULL N,sum;
	cin >> N;
	
	sum=N*(N+1)/2;
	sum-=(3*(N/3)*(N/3+1)/2+5*(N/5)*(N/5+1)/2-15*(N/15)*(N/15+1)/2);
	
	cout << sum << endl;
	return 0;
}