#include<stdio.h>
int main(void)
{
    long int n;
    scanf("%ld",&n);
    long int a = n / 3;
    long int b = n / 5;
    long int c = n / 15;
    long int sum,sum3,sum5,sum15;
    sum = n*(n+1)/2;
    sum3 = 3*a*(a+1)/2;
    sum5 = 5*b*(b+1)/2;
    sum15 = 15*c*(c+1)/2;
    long int ans = sum -sum3 -sum5 + sum15;
    printf("%ld\ns",ans);
    return 0;
}