#include<stdio.h>

int main()
{
    int N;
    int i;
    long int sum = 0;
    scanf("%d",&N);
    for (i=1;i<=N;i++) {
        sum += i;
    }
    for (i=1;i<=N/3;i++) {
        sum -= 3*i;
    }
    for (i=1;i<=N/5;i++) {
        sum -= 5*i;
    }
    for (i=1;i<=N/15;i++) {
        sum += 15*i;
    }
    printf("%ld\n",sum);
    return 0;
}