#include <stdio.h>

int main(){
   int i,n;
   long s;

   scanf("%d",&n);
   s=0;
   for (i=1;i<=n;i++) 
   if (i%3==0 || i%5==0) continue;
   else                  s+=i;
   printf("%ld\n",s);
   return 0;
}
