#include<iostream>
#include"bits/stdc++.h"
#include<math.h>
#include<string.h>
using namespace std;
#define ll long long
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define rep(i, j) FOR(i, 0, j, 1)
#define rrep(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define endl "\n"
#define MOD 1000000007
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void solve()
{
	int n,flag=0;
	cin>>n;
	while(n>0)
	{
		int x=n%10;
		if(x==7)
			{
				flag=-1;
			}
		n=n/10;
	}
	if(flag==-1)
		cout<<"Yes";
	else
		cout<<"No";
}
void solve1()
{
	ll n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0)
			continue;
		if(i%5==0)
			continue;
		sum+=i;
	}
	cout<<sum;
}
int main()
{
	fastio();
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	//solve();
	solve1();
	return 0;
}