#include<iostream>
#include <cmath>
int main(){
    long long N;
    long long c3, c5, c15;
    long long sum3=0, sum5=0, sum15=0;
    std::cin >> N;
    c3 = N/3;
    c5 = N/5;
    c15 = N/15;
    if(c3>0){
        sum3 = c3*(3+3*c3)/2;
    }
    if(c5>0){
        sum5 = c5*(5+5*c5)/2;
    }
    if(c15>0){
        sum15 = c15*(15+15*c15)/2;
    }
    printf("%lld\n", N*(N+1)/2-(sum3+sum5-sum15));
    return 0;
}