#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int ans = 0;
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		if(i % 3 && i % 5)
			ans += i;
	}
	cout << ans;

	return 0;
}

