#include <bits/stdc++.h>
using namespace std;
#define ll	        long long
#define all(v)      (v).begin() , (v).end()
#define vi          vector <ll>
#define vii         vector <pair<ll,ll>>
#define ii          pair<int,int>
#define lp(i,a,b)	for(int i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
const ll mod=1e9+7,MAX=2e5+7;
void fast();
int main()
{
    fast();
    ll n;
    cin>>n;
    ll res=0;
    res=n*(n+1)/2;
    res-=((n/3)*(n/3+1)/2)*3;
    res-=((n/5)*(n/5+1)/2)*5;
    res+=((n/15)*(n/15+1)/2)*15;
    cout<<res;
}

void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/
