#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long ll;

int main()
{
    ll n,a3,a5,a15,ans;
    scanf("%lld",&n);

    a3=n/3;
    a5=n/5;
    a15=n/15;

    ans=((n+1)*n/2)-3*((a3+1)*(a3)/2)-5*((a5+1)*(a5)/2)+15*((a15+1)*(a15)/2);

    printf("%lld\n",ans);
}