#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n,ans=0;
	string s;

	cin >> n;

	forll(i, 0, n)
	{
		if ((i+1) % 3 != 0 && (i+1) % 5 != 0)
		{
			ans += i + 1;
		}
	}


	cout << ans << endl;

}