#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define ins insert
#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define sz(X) ((int)X.size())
#define rsz resize
#define maxel max_element
#define minel min_element
#define ub upper_bound
#define lb lower_bound
#define make_unique(X) sort(all(X)); (X).resize(distance((X).begin(), unique(all(X))));

#define FORN(i, a, b, in) for (int i = (a); i < (b); i += in)
#define FOR(i,a,b) for (auto i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto a : x)

// TYPES
typedef long long ll;
typedef long double ld;
typedef double db;

typedef pair<int,int> pii; 
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef pair<db,db> pdb;
typedef pair<string,string> pss;

typedef vector< pii > vpii;
typedef vector< pll > vpll; 
typedef vector< pss > vpss;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector< vi > vvi;
typedef vector< vll > vvll;
typedef vector< vb > vvb;

template<class T>using uset = unordered_set<T>;
template<class T>using mset = multiset<T>;
template<class T>using umset = unordered_multiset<T>;
template<class A, class B>using umap = unordered_map<A,B>;
template<class T>using minpq = priority_queue<T,vector<T>,greater<T>>;
template<class T>using maxpq = priority_queue<T,vector<T>,less<T>>;
template<size_t SZ>using bset = bitset<SZ>;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

// FUNCTIONS
template<class T> bool amin(T& a, const T& b) {return b<a?a=b,1:0;}
template<class T> bool amax(T& a, const T& b) {return a<b?a=b,1:0;} 
template<typename T> T sqr(T x) {return x*x;}
template<typename T> T cdiv(T a, T b) {return a/b+!(a<0||a%b == 0);}

// INPUT //
template<class A> bool re(complex<A>& c);
template<class A, class B> bool re(pair<A,B>& p);
template<class A> void re(vector<A>& v);
template<class A, size_t SZ> void re(array<A,SZ>& a);
 
template<class T> bool re(T& x) { if (cin >> x) return true; else return false;}
bool re(db& d) { string t; bool ok = re(t); d = stod(t); return ok; }
bool re(ld& d) { string t; bool ok = re(t); d = stold(t); return ok; }
template<class H, class... T> bool re(H& h, T&... t) { if (re(h)) { re(t...); return true; } return false; }
 
template<class A> void re(complex<A>& c) { A a,b; re(a,b); c = {a,b}; }
template<class A, class B> void re(pair<A,B>& p) { re(p.ff, p.ss); }
template<class A> void re(vector<A>& x) { trav(&a,x) re(a); }
template<class A, size_t SZ> void re(array<A,SZ>& x) { trav(&a,x) re(a); }

// OUTPUT
template<class A> void pr(A x) { cout << x; }
template<class H, class... T> void pr(const H& h, const T&... t) { 
	pr(h); pr(t...); }
void pln() { pr("\n"); }
template<class H, class... T> void pln(const H& h, const T&... t) { 
	pr(h); pln(t...); }
void ps() { pr("\n"); } // print w/ spaces
template<class H, class... T> void ps(const H& h, const T&... t) { 
	pr(h); if (sizeof...(t)) pr(" "); ps(t...); }

template<class A> void pr(vector<A> x) { trav(a, x) pr(a, " "); }
template<class A> void pln(vector<A> x) { trav(a, x) pr(a, " "); pln(); }

// TO_STRING
#define ts to_string
string ts(char c) { return string(1,c); }
string ts(bool b) { return b ? "true" : "false"; }
string ts(const char* s) { return (string)s; }
string ts(string s) { return s; }
template<class A> string ts(complex<A> c) { 
	stringstream ss; ss << c; return ss.str(); }
string ts(vector<bool> v) { 
	string res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string ts(bitset<SZ> b) {
	string res = ""; F0R(i,SZ) res += char('0'+b[i]);
	return res; }
template<class A, class B> string ts(pair<A,B> p);
template<class T> string ts(T v) { // containers with begin(), end()
	bool fst = 1; string res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += ts(x);
	}
	res += "}"; return res;
}
template<class A, class B> string ts(pair<A,B> p) {
	return "("+ts(p.ff)+", "+ts(p.ss)+")"; }

// FILE I/O
#pragma GCC diagnostic ignored "-Wunused-result"
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

// DEBUG
template<class H> void DBG(const char *sdbg, H h) { cerr<<sdbg<<" = "<<ts(h)<<"]"<<endl; }
template<class H, class... T> void DBG(const char *sdbg, H h, T... t) {
	while(*sdbg!=',') cerr<<*sdbg++;
	cerr<<" = "<<ts(h)<<", ";
	DBG(sdbg+1, t...);
}

#ifdef LOCAL // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [", DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) 0
#endif

// VARIABLES
const db pi = acos(-1.0);
const int INF = 1e9 + 7;
const ll llINF = ((ll)1e18) + 7LL;
const int mxN = 1e5 + 7;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main() {
	setIO();
	
	int n;
	re(n);
	
	ll ans = 0;
	FOR(i, 1, n + 1) {
		if (i % 3 and i % 5) {
			ans += i;
		}
	}
	pln(ans);
	// you should actually read the stuff at the bottom
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smthn instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 3636