#include<stdio.h>
int main ()
{   long long  n;
   scanf("%lld",&n);
   long long sum=0;
   long long  a3=n/3,a5=n/5,a15=n/15;
   sum=-a3*(3*a3+3)/2-a5*(5*a5+5)/2+n*(n+1)/2+a15*(15*a15+15)/2;
   printf("%lld",sum);
}