#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const ll o=1e18;
const int mm=1e6;
ll d[mm];
ll dd[mm];
ll ans[mm];
int main()
{
	ll n,m,i,j,k,kk,a,b,t,ss,s;
	cin>>n;
    s=0;
    for(i=1;i<=n;i++)
    {
    	if(i%3!=0&&i%5!=0)
    	s+=i;
	}
	cout<<s<<endl;
}
