#include<bits/stdc++.h>

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
	//cin >> tt;
	
	while (tt--)
	{
		int n; cin >> n;
		
		int sum = 0;
		for (int i = 1; i <= n; i++)
		{
			if(i % 3 == 0 or i % 5 == 0) {}
			else
			{
				sum += i;
			}
		}
		cout << sum ;
		
	}
    return 0;
}
