/*
 * FileName:     B
 * CreatedDate:  2020-04-12 20:56:29 +0900
 * LastModified: 2020-04-12 21:57:37 +0900
 */

#include <stdio.h>

int main(void){
    long int n;
    scanf("%ld",&n);
    long int count=0;
    for(long int i=0;i<n;i++){
        if(i%3!=0&&i%5!=0){
            count+=i;
        }
    }
    printf("%ld\n",count);
    return 0;
}
