#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vii vector<int, int>
#define po pop_back
#define hell 1000000007
using namespace std;

void solve(){
	ll n;
	cin>>n;
	ll ans = n*(n+1)/2;
	int t = n/3;
	ans -= ((3+3+(t-1)*3)*t)/2;
	t = n/5;
	ans -= ((5+5+(t-1)*5)*t)/2;
	t = n/15;
	ans += ((15+15+(t-1)*15)*t)/2;
	cout<<ans;
}

int main(){
	int t = 1;
	//cin>>t;
	while(t--){
		solve();
	}
}