#include <bits/stdc++.h>

#define nl '\n'
#define F fisrt
#define S second
#define pb push_back
#define mp make_pair
#define REP(i,a,b) for(int i = a; i < b; i++)

#define Fizz -1
#define Buzz -2
#define FizzBuzz -3

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef stack<int> si;
typedef deque<int> di;
typedef pair<int,int> pi;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//your code here
	int n; cin >> n;
	ll sum = 0;
	
	REP(i,0,n)
		if(i%3!=0&&i%5!=0)
			sum+=i;
	cout << sum  << endl;
}
