//abc162_b.cpp
//Sun Apr 12 20:57:50 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n;
	cin >> n;

	ll ans = 0;
	for (ll i=1;i<=n;i++){
		if (i%3==0 || i%5==0){
			continue;
		}else {
			ans += i;
		}
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}