#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000000;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;

int main(){  
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n,k;
	scanf("%d",&n);
	ll sum=0;
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0) sum+=i;
	} 
	printf("%lld",sum);

    return 0;
}


