#include "bits/stdc++.h" 
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rerep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
int main(){
    ll n;
    cin>>n;
    ll tri=n;
    ll pen=n;
    while(1){
        if(tri%3==0)break;
        tri-=1;
    }
    while(1){
        if(pen%5==0)break;
        pen-=1;
    }
    ll sum_3=(tri/3)*(3+tri)/2;
    ll sum_5=(pen/5)*(5+pen)/2;
    ll fif=n;
    while(1){
        if(fif%15==0)break;
        fif-=1;
    }
    ll sum_15=(fif/15)*(15+fif)/2;
    ll sum=n*(n+1)/2;
    ll ans=sum-sum_5-sum_3+sum_15;
    cout<<ans<<endl;
    return 0;
}