#include <stdio.h>

int main()
{
    int n;
    long long ans = 0;
    scanf("%d", &n);
    for (int i = 0; i <= n; i++)
    {
        if (!(i % 3 == 0 || i % 5 == 0))
            ans += (long long)i;
    }
    printf("%lld", ans);
    return 0;
}