#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    ll sum=n*(n+1)/2;
    ll l1=n%3;
    l1=n-l1;
    ll l2=n%5;
    l2=n-l2;
    ll l3=n%15;
    l3=n-l3;
    ll n1=(l1-3)/3+1;
    ll n2=(l2-5)/5+1;
    ll n3=(l3-15)/15+1;
    //cout<<n1<<n2<<n3<<l1<<l2<<l3;
    ll s1=n1*(3+l1);
    s1=s1/2;
    ll s2=n2*(5+l2);
    s2=s2/2;
    ll s3=n3*(15+l3);
    s3=s3/2;
    //cout<<s1<<" "<<s2<<" "<<s3;
    cout<<sum-s1-s2+s3;
    return 0;
}
