#include <stdio.h>

int main() {

    long long int N;
    scanf("%lld", &N);

    long long int s=N*(N+1)/2;

    long long int l1=N-N%3;
    long long int l2=N-N%5;
    long long int l3=N-N%15;

    long long int s1 = l1*(l1+3)/6;
    long long int s2 = l2*(l2+5)/10;
    long long int s3 = l3*(l3+15)/30;

    printf("%lld\n", s+s3-s1-s2);

    return 0;
}