#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long int ll;
using namespace std;
int main(){
	io;
	ll n;
	ll summ = 0;
	cin >> n;
	for(int i = 1;i <= n;++i){
		if(i % 3 != 0 && i % 5 != 0){
			summ += i;
		}
	}
	cout << summ;
	return 0;
}