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

int main(){
	long long a;
    scanf("%lld",&a);
    long long sum=a*(a+1)/2;
    long long sumthree=(3+(a/3)*3)*(a/3)/2;
    long long sumfive=(5+(a/5)*5)*(a/5)/2;
    long long sumfiveteen=(15+(a/15)*15)*(a/15)/2;
    if(a>=15){
    	printf("%d\n",sum-sumthree-sumfive+sumfiveteen);
	}else if(a>=5){
    	printf("%d\n",sum-sumthree-sumfive);
	}else if(a>=3){
    	printf("%d\n",sum-sumthree);
	}else{
		if(a==2){
			printf("3\n");
		}else{
			printf("1\n");
		}
	}
    return 0;

}