#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
// #define NMAX 1000000000
ll N,a,b,c;
vi V,U;

ll solve(){

	ll ans = 0;
	rp(i,1,N+1){
		if(i%15==0){
			// ans += i;
		}
		else if(i%3==0){
			// ans += i;
		}
		else if(i%5==0){
			// ans += i;
		}
		else{
			ans += i;
		}

	}
	return ans;
}

int main(){
	cin>>N;
	cout<< solve() <<endl;
}
