#include<stdio.h>
#include<stdlib.h>

int main() {
    long long unsigned int N, n_three, n_five, n_fifteen;
    long long unsigned int l_three, l_five, l_fifteen;

    scanf("%lld", &N);
    
    n_three = N / 3;
    l_three = N - N % 3;
    n_five = N / 5 ;
    l_five = N - N % 5;
    n_fifteen = N / 15;
    l_fifteen = N - N % 15;

    printf("%lld\n",N*(1 + N)/2 - n_three*(3 + l_three)/2 - n_five*(5+l_five)/2 + 
            n_fifteen*(15 + l_fifteen)/2 );

    return 0;
}