#include <stdio.h>

int main()
{
    int all[1000002];

    for (int i = 0; i <= 1000001; i++)
    {
        all[i] = 0;
        if (i % 3 == 0)
            all[i] = 1;
        else if(i%5==0)
            all[i] = 1;
    }

    int x;
    if(scanf("%d", &x)==1){}
    long z=0;

    for (int i = 1; i <= x; i++)
    {
        if (all[i] == 0)
            z =(long) z + (long)i;
    }

    printf("%ld",z);
    printf("\n");
    return 0;
}