#include<stdio.h>
long long SUM(int d,long long n){
	return d*n*(n+1)/2;
}
int main(void){
	long long n,thr,fiv,fif;
	scanf("%lld", &n);
	thr=n/3;
	fiv=n/5;
	fif=n/15;
	printf("%lld",SUM(1,n)-SUM(3,thr)-SUM(5,fiv)+SUM(15,fif));
	return 0;
}
