#include<stdio.h>
#include<string.h>

int main()
{
	long long int N;
	scanf("%ld", &N);

	long long int ans = N*(N+1)/2;
	
	long long int f = (N-N%3)/3;
	long long int b = (N-N%5)/5;
	long long int fb = (N-N%15)/15;
	
	ans = ans - 3*(f*(f+1)/2) - 5*(b*(b+1)/2) + 15*(fb*(fb+1)/2);
	
	printf("%ld", ans);
	
}
