#include <stdio.h>

int main(void)
{
    int N, c;
    long long ans = 0;
    scanf("%d", &N);
    for (c = 1; c <= N; ++c)
    {
        if (c % 3 != 0 && c % 5 != 0)
        {
            ans += c;
        }
    }
    printf("%ld", ans);
    return 0;
}