#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void){
	int n;
	cin >> n;
	ll ans = 0;
	rep(i, 1, n + 1) {
		if (i % 3 == 0 || i % 5 == 0)continue;
		ans += i;
	}
	cout << ans << endl;
	return 0;
}