#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll n;cin>>n;
	ll p = n/3;
	ll q = n/5;
	ll r = n/15;
	ll sum = n*(n+1)/2;
	ll sum1 = 3*p*(p+1)/2;
	ll sum2 = 5*q*(q+1)/2;
	ll sum3 = 15*r*(r+1)/2;
	sum = sum-sum1-sum2+sum3;
	cout<<sum<<endl;
}