#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define N 100010
#define M 200010
#define A 110
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n;
	ll ans = 0;
	
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		if(i % 3 == 0 || i % 5 == 0){
			continue;
		}
		
		ans += (ll)i;
	}
	
	cout << ans << endl;
	return 0;
}