#include<stdio.h>

int main(){
	long long int N, ret, three, five, fifteen;
	scanf("%lld", &N);
	ret = three = five = fifteen = 0;
	if(N - N%3 > 0){
		three = (N - N%3) / 3;
		three = three*(three + 1) / 2;
		three *= 3;
	}
	if(N - N%5 > 0){
		five = (N - N%5) / 5;
		five = five*(five + 1) / 2;
		five *= 5;
	}
	if(N - N%15 > 0){
		fifteen = (N - N%15) / 15;
		fifteen = fifteen*(fifteen + 1) / 2;
		fifteen *= 15;
	}
	ret = N*(N+1) / 2 - three - five + fifteen;
	printf("%lld\n", ret);
	return 0;
}