#include <stdio.h>
int main(void){
    // Your code here!
    int n, sum = 0;
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        if( i%3 == 0 || i%5 ==0 )continue;
        sum += i;
    }
    printf("%d", sum);
}
