// In The Name of Almighty Allah
#include<bits/stdc++.h>
using namespace std;
#define             fastio              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define             ff                  first
#define             ss                  second
#define             int                 long long
#define             pb                  push_back
#define             pf                  push_front
#define             pii                 pair<int,int>
#define             print(x)            for(auto it : x) cout<<it<<' '; cout<<'\n';
#define             debug(x)            cout << #x << " --->> " << x << endl;
#define             mod                 1000000007
#define             inf                 1e18
#define             PI                  (acos(-1))
#define             eps                 (1e-8)
#define             clear(x)            memset(x,0,sizeof(x));
const int mxn = 1e6 + 5;
int ara[mxn];
main()
{
	fastio;
	int a, b, c, x, y, z, p, q, r, n, m;
	cin >> n;
	vector<int>v = {3, 5, 15};
	for (auto it : v)
	{
		int x = it;
		while (x <= n)
		{
			ara[x] = 1;
			x += it;
		}
	}
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		sum += (ara[i] == 0) ? i : 0;
	}
	cout << sum << endl;

}
