#include <stdio.h>
int main(void)
{
  int N;
  long sum = 0;
    scanf("%d",&N);
    while(N > 0){
        if(N % 3 != 0 && N % 5 !=0 )
            sum = sum + N;
        N = N - 1;
    }
    printf("%ld\n",sum);
    return 0;
}