#include <bits/stdc++.h>

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,i,j;
	scanf("%d",&n);
	// printf("n: %d\n",n);
	ll sum = 0;
	for(i=1;i<=n;i++){
		if(i%3 == 0 || i %5 == 0){continue;}
		// printf("halo\n");
		sum += i;
	}
	printf("%lld\n",sum);
	return 0;
};