
// Problem : B - FizzBuzz Sum
// Contest : AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int ans = 0;
		for(int i=1;i<=n;++i)
		{
			if(i%3==0&&i%5==0)
			continue;
			else if(i%3==0)
			continue;
			else if(i%5==0)
			continue;
			else
			ans+=i;
		}
		cout<<ans<<"\n";    	
    }
    return 0;
}

