#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define abs(a) ((a) > 0 ? (a) : (-1 * (a)))
#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)
#define rep2(i, s, e) for ((i) = (s); (i) < (e); (i)++)
#define LIM (1000000007)

int main(void)
{

    int n, i;
    long long s = 0;
    scanf("%d", &n);
    rep2(i, 1, n + 1)
    {
        if (i % 3 != 0 && i % 5 != 0)
            s += i;
    }
    printf("%d", s);

    return 0;
}
