#include<stdio.h>
int main(){
    long int n;
    scanf("%ld",&n);
    unsigned long int fb[n+1];
    for(long int i=1;i<=n;i++) {
        fb[i]=i;
    }
    for (long int i=1;i<=n;i++) {
        if (i%3==0||i%5==0) {
            fb[i]=0;
        }
    }
    unsigned long int s=0;
    for (long int i=1;i<=n;i++) {
        s+=fb[i];
    }
    printf("%lu",s);
    return 0;

}