#include<bits/stdc++.h>
 
#define ll long long 
#define mkp make_pair 
#define fi first 
#define se second
#define pb push_back 
#define pf push_front 
#define ppb pop_back 
#define ppf pop_front 

using namespace std ;
 
int z , o , ans ;
 
int main(){
 

	int n ;

	cin >> n ;

	for( int i = 1 ; i <= n ; i ++ ){

		if( i % 3 == 0 || i % 5 == 0 ){

			continue ;

		}

		else{

			ans += i ;

		}

	}

	cout << ans ;

 
}