#include <stdio.h>

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