#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>

using namespace std;
const int maxn = 1e4 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long ll;
#define pi 3.1415926535
// luxi

ll n, sum;
int main(){
	cin >> n;
	for(ll i = 1; i <= n; i++){
		if(i % 3 != 0 && i % 5 != 0){
			sum += i;
		}
	}
	cout << sum << endl;
}