#include <stdio.h>
int main()
{
    long long n;
    scanf("%lld",&n);
    long long ans = 0;

    for (long long i = 1; i <= n; ++i)
    {
        if (i % 3 == 0 || i % 5 == 0) {
		continue;}
        else {
		ans += i;
	}
    }
    printf("%lld",ans);
    return 0;
}