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