#include<iostream>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    ll suxx=n*(n+1)/2;
    ll m3=n/3;
    ll m5=n/5;
    ll m15=n/15;
    ll s3= m3*(2*3 +(m3 -1)*3)/2;
    ll s5= m5*(2*5 +(m5 -1)*5)/2;
    ll s15= m15*(2*15 +(m15 -1)*15)/2;
    ll sux=s3+s5-s15;
    cout<<suxx-sux;
    return 0;
}