#include <stdio.h>
signed main(){
    int N;
    int i;
    long long sum=0;
    scanf("%d",&N);
    for(i=1;i<=N;i++){
        if(i%3!=0){
            if(i%5!=0){
              sum+=i;
            }
        }
    }
    printf("%lld\n",sum);
    return(0);
}