#include <bits/stdc++.h>

using namespace std;
long long sum(long long n)
{
    return (n * (n+1))/2;
}

int main()
{
    long long n;
    cin>>n;
    long long cn = n;
    long long cn1, cn2;
    cn1 = n;
    cn2 = n;
    while(cn%3!=0)
    {
        cn--;
    }
    while(cn1%5==0)
    {
        cn1--;
    }
    while(cn2%15==0)
    {
        cn2--;
    }
    long long s  = 0;
    s = s + sum(n) - 3* sum(cn/3) - 5*sum (cn/5) + 15*sum(cn/15);
    cout<<s<<"\n";

    return 0;
}
