#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = (1e6)+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        int ans = (n*(n+1))/2;
        int sub = n/3;
        sub*=(sub+1);sub/=2;
        ans-=(3*sub);
        sub = n/5;
        sub*=(sub+1);sub/=2;
        ans-=(5*sub);
        sub = n/15;
        sub*=(sub+1);sub/=2;
        ans+=(15*sub);
        cout<<ans<<endl;
    }
    return 0;
}
/*
Test Case
*/
