#include <stdio.h>

int main(void){
    int i=1,n;
    long int ans=0;
    scanf("%d",&n);

    while(i<=n){
        if( (i%3!=0) && (i%5!=0) ){
            ans += (long int)i;
        }
        i++;
    }

    printf("%ld\n",ans);

    return 0;
}